<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE `sa_blackout_dates` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `facility_id` BIGINT UNSIGNED NOT NULL,
            `facility_unit_id` BIGINT UNSIGNED NULL,
            `blackout_date` DATE NOT NULL,
            `start_time` TIME NULL,
            `end_time` TIME NULL,
            `reason` VARCHAR(500) NULL,
            `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `created_by` BIGINT UNSIGNED NULL,
            INDEX `idx_sa_bo_facility` (`facility_id`, `blackout_date`),
            INDEX `idx_sa_bo_unit` (`facility_unit_id`, `blackout_date`),
            CONSTRAINT `fk_sa_bo_facility` FOREIGN KEY (`facility_id`) REFERENCES `sa_facilities`(`id`) ON DELETE CASCADE,
            CONSTRAINT `fk_sa_bo_unit` FOREIGN KEY (`facility_unit_id`) REFERENCES `sa_facility_units`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `sa_blackout_dates`",
];
