<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `warehouses` (
            `id`                   BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code`                 VARCHAR(20) NOT NULL,
            `name_ar`              VARCHAR(200) NOT NULL,
            `name_en`              VARCHAR(200) NULL,
            `warehouse_type`       VARCHAR(30) NOT NULL DEFAULT 'general' COMMENT 'general, sports_shop, cafeteria, gym, medical, maintenance',
            `location_ar`          VARCHAR(300) NULL,
            `keeper_employee_id`   BIGINT UNSIGNED NULL,
            `capacity_units`       INT UNSIGNED NULL,
            `branch_id`            BIGINT UNSIGNED NULL,
            `phone`                VARCHAR(30) NULL,
            `is_active`            TINYINT(1) NOT NULL DEFAULT 1,
            `notes`                TEXT NULL,
            `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_warehouses_code` (`code`),
            INDEX `idx_warehouses_type` (`warehouse_type`),
            INDEX `idx_warehouses_branch` (`branch_id`),
            INDEX `idx_warehouses_keeper` (`keeper_employee_id`),
            INDEX `idx_warehouses_active` (`is_active`),
            CONSTRAINT `fk_warehouses_keeper` FOREIGN KEY (`keeper_employee_id`) REFERENCES `employees` (`id`) ON DELETE SET NULL,
            CONSTRAINT `fk_warehouses_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `warehouses`",
];
