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

    UNIQUE INDEX `car_models_slug_key`(`slug`),
    INDEX `car_models_brand_id_deleted_at_idx`(`brand_id`, `deleted_at`),
    INDEX `car_models_is_active_deleted_at_idx`(`is_active`, `deleted_at`),
    INDEX `car_models_is_popular_deleted_at_idx`(`is_popular`, `deleted_at`),
    INDEX `car_models_is_discontinued_deleted_at_idx`(`is_discontinued`, `deleted_at`),
    UNIQUE INDEX `car_models_brand_id_name_key`(`brand_id`, `name`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `car_models` ADD CONSTRAINT `car_models_brand_id_fkey` FOREIGN KEY (`brand_id`) REFERENCES `brands`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
