-- CreateTable
CREATE TABLE `poi_files` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `poi_id` INTEGER NOT NULL,
    `file_id` INTEGER NOT NULL,
    `upload_order` INTEGER NOT NULL DEFAULT 0,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,

    INDEX `poi_files_poi_id_idx`(`poi_id`),
    INDEX `poi_files_file_id_idx`(`file_id`),
    UNIQUE INDEX `poi_files_poi_id_file_id_key`(`poi_id`, `file_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `poi_files` ADD CONSTRAINT `poi_files_poi_id_fkey` FOREIGN KEY (`poi_id`) REFERENCES `points_of_interest`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `poi_files` ADD CONSTRAINT `poi_files_file_id_fkey` FOREIGN KEY (`file_id`) REFERENCES `files`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
