/*
  Warnings:

  - You are about to alter the column `area` on the `lakes` table. The data in that column could be lost. The data in that column will be cast from `Int` to `Double`.

*/
-- AlterTable
ALTER TABLE `lakes` ADD COLUMN `challenges_opportunities` TEXT NULL,
    ADD COLUMN `ecological_status` TEXT NULL,
    ADD COLUMN `environmental_stressors` TEXT NULL,
    ADD COLUMN `historical_background` TEXT NULL,
    ADD COLUMN `key_findings` TEXT NULL,
    ADD COLUMN `monitoring_activities` TEXT NULL,
    ADD COLUMN `nbs_implemented` TEXT NULL,
    ADD COLUMN `socio_economic_context` TEXT NULL,
    MODIFY `area` DOUBLE NULL;

-- CreateTable
CREATE TABLE `lake_files` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `lake_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 `lake_files_lake_id_idx`(`lake_id`),
    INDEX `lake_files_file_id_idx`(`file_id`),
    UNIQUE INDEX `lake_files_lake_id_file_id_key`(`lake_id`, `file_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `lake_files` ADD CONSTRAINT `lake_files_lake_id_fkey` FOREIGN KEY (`lake_id`) REFERENCES `lakes`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

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