-- CreateTable
CREATE TABLE `ads` (
    `uuid` VARCHAR(191) NOT NULL,
    `name` VARCHAR(191) NOT NULL,
    `created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
    `updated_at` TIMESTAMP(6) NOT NULL,

    UNIQUE INDEX `ad_name_unique`(`name`),
    INDEX `ad_created_at_idx`(`created_at`),
    PRIMARY KEY (`uuid`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `ad_images` (
    `uuid` VARCHAR(191) NOT NULL,
    `ad_uuid` VARCHAR(191) NOT NULL,
    `filename` VARCHAR(191) NOT NULL,
    `original_filename` VARCHAR(191) NOT NULL,
    `created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
    `updated_at` TIMESTAMP(6) NOT NULL,

    UNIQUE INDEX `ad_image_filename_unique`(`filename`),
    INDEX `ad_image_created_at_idx`(`created_at`),
    PRIMARY KEY (`uuid`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `ad_images` ADD CONSTRAINT `ad_images_ad_uuid_fkey` FOREIGN KEY (`ad_uuid`) REFERENCES `ads`(`uuid`) ON DELETE CASCADE ON UPDATE CASCADE;
