-- CreateTable
CREATE TABLE `feature_categories` (
    `id` VARCHAR(191) NOT NULL,
    `name` VARCHAR(120) NOT NULL,
    `slug` VARCHAR(140) NOT NULL,
    `is_active` BOOLEAN NOT NULL DEFAULT true,
    `deleted_at` DATETIME(3) NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,

    UNIQUE INDEX `feature_categories_name_key`(`name`),
    UNIQUE INDEX `feature_categories_slug_key`(`slug`),
    INDEX `feature_categories_is_active_deleted_at_idx`(`is_active`, `deleted_at`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `car_features` (
    `id` VARCHAR(191) NOT NULL,
    `category_id` VARCHAR(191) NOT NULL,
    `name` VARCHAR(120) NOT NULL,
    `slug` VARCHAR(180) NOT NULL,
    `icon_url` VARCHAR(500) NULL,
    `is_popular` BOOLEAN NOT NULL DEFAULT false,
    `is_active` BOOLEAN NOT NULL DEFAULT true,
    `deleted_at` DATETIME(3) NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,

    UNIQUE INDEX `car_features_slug_key`(`slug`),
    INDEX `car_features_category_id_deleted_at_idx`(`category_id`, `deleted_at`),
    INDEX `car_features_is_active_deleted_at_idx`(`is_active`, `deleted_at`),
    INDEX `car_features_is_popular_deleted_at_idx`(`is_popular`, `deleted_at`),
    UNIQUE INDEX `car_features_category_id_name_key`(`category_id`, `name`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `car_features` ADD CONSTRAINT `car_features_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `feature_categories`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
