-- Migration 016 : tables du carousel de la page d'accueil

CREATE TABLE IF NOT EXISTS `carousel_slides` (
    `id`            INT UNSIGNED  NOT NULL AUTO_INCREMENT,
    `folder`        VARCHAR(255)  NOT NULL,
    `sort_order`    INT           NOT NULL DEFAULT 0,
    `is_active`     TINYINT(1)   NOT NULL DEFAULT 1,
    `is_first`      TINYINT(1)   NOT NULL DEFAULT 0,
    `text_position` VARCHAR(20)  NULL DEFAULT NULL,
    `created_at`    TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`    TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uq_carousel_folder` (`folder`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `carousel_slide_translations` (
    `id`           INT UNSIGNED  NOT NULL AUTO_INCREMENT,
    `slide_id`     INT UNSIGNED  NOT NULL,
    `locale`       VARCHAR(5)    NOT NULL,
    `alt`          VARCHAR(500)  NOT NULL DEFAULT '',
    `overlay_html` TEXT          NULL DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uq_slide_locale` (`slide_id`, `locale`),
    FOREIGN KEY (`slide_id`) REFERENCES `carousel_slides`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
