<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `facilities` (
            `id`                       BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code`                     VARCHAR(50) NOT NULL,
            `name_ar`                  VARCHAR(200) NOT NULL,
            `name_en`                  VARCHAR(200) NULL,
            `facility_type`            VARCHAR(50) NOT NULL COMMENT 'pitch, court, hall, lane, table, device, track, pool',
            `location`                 VARCHAR(50) NOT NULL COMMENT 'indoor, outdoor',
            `capacity`                 INT UNSIGNED NULL,
            `hourly_rate_member`       DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `hourly_rate_nonmember`    DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `hourly_rate_member_pm`    DECIMAL(15,2) NULL,
            `hourly_rate_nonmember_pm` DECIMAL(15,2) NULL,
            `linked_discipline_id`     BIGINT UNSIGNED NULL,
            `config_json`              JSON NULL,
            `is_active`                TINYINT(1) NOT NULL DEFAULT 1,
            `is_archived`              TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at`              TIMESTAMP NULL DEFAULT NULL,
            `archived_by`              BIGINT UNSIGNED NULL,
            `created_at`               TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at`               TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            `created_by`               BIGINT UNSIGNED NULL,
            `updated_by`               BIGINT UNSIGNED NULL,
            UNIQUE KEY `uq_facilities_code` (`code`),
            INDEX `idx_facilities_type` (`facility_type`),
            INDEX `idx_facilities_active` (`is_active`),
            INDEX `idx_facilities_discipline` (`linked_discipline_id`),
            CONSTRAINT `fk_facilities_discipline` FOREIGN KEY (`linked_discipline_id`) REFERENCES `sport_disciplines`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `facilities`",
];
