<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE `sa_facility_units` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `facility_id` BIGINT UNSIGNED NOT NULL,
    `code` VARCHAR(30) NOT NULL,
    `name_ar` VARCHAR(200) NOT NULL,
    `name_en` VARCHAR(200) NULL,
    `unit_type` VARCHAR(30) NOT NULL COMMENT 'lane, court, pitch, ring, mat, room',
    `booking_mode` VARCHAR(20) NOT NULL DEFAULT 'exclusive' COMMENT 'exclusive, shared',
    `max_capacity` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'shared: max concurrent; exclusive: max participants',
    `sort_order` INT UNSIGNED NOT NULL DEFAULT 0,
    `dimensions_json` JSON NULL COMMENT '{\"length\":50,\"width\":2.5}',
    `config_json` JSON NULL COMMENT 'unit-specific config',
    `is_active` TINYINT(1) NOT NULL DEFAULT 1,
    `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,
    UNIQUE KEY `uq_sa_fu_code` (`facility_id`, `code`),
    INDEX `idx_sa_fu_facility` (`facility_id`),
    INDEX `idx_sa_fu_mode` (`booking_mode`),
    CONSTRAINT `fk_sa_fu_facility` FOREIGN KEY (`facility_id`) REFERENCES `sa_facilities`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
    'down' => "DROP TABLE IF EXISTS sa_facility_units;"
];
