<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE `sa_academy_contracts` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `contract_number` VARCHAR(50) NOT NULL,
            `academy_id` BIGINT UNSIGNED NOT NULL,
            `contract_type` VARCHAR(30) NOT NULL DEFAULT 'revenue_share' COMMENT 'revenue_share, fixed_rent, hybrid',
            `start_date` DATE NOT NULL,
            `end_date` DATE NOT NULL,
            `club_commission_pct` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
            `academy_share_pct` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
            `fixed_monthly_rent` DECIMAL(10,2) NOT NULL DEFAULT 0.00,
            `minimum_revenue_guarantee` DECIMAL(10,2) NOT NULL DEFAULT 0.00,
            `deposit_amount` DECIMAL(10,2) NOT NULL DEFAULT 0.00,
            `deposit_status` VARCHAR(20) NOT NULL DEFAULT 'pending' COMMENT 'pending, paid, returned, forfeited',
            `contract_pdf_path` VARCHAR(500) NOT NULL,
            `status` VARCHAR(20) NOT NULL DEFAULT 'draft' COMMENT 'draft, pending_approval, active, suspended, expired, terminated',
            `approved_by` BIGINT UNSIGNED NULL,
            `approved_at` TIMESTAMP NULL,
            `terminated_by` BIGINT UNSIGNED NULL,
            `terminated_at` TIMESTAMP NULL,
            `termination_reason` TEXT NULL,
            `terms_json` JSON NULL,
            `notes` TEXT NULL,
            `is_archived` TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at` TIMESTAMP NULL,
            `archived_by` BIGINT UNSIGNED NULL,
            `branch_id` 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_sa_ac_number` (`contract_number`),
            INDEX `idx_sa_ac_academy` (`academy_id`),
            INDEX `idx_sa_ac_status` (`status`),
            INDEX `idx_sa_ac_dates` (`start_date`, `end_date`),
            CONSTRAINT `fk_sa_ac_academy` FOREIGN KEY (`academy_id`) REFERENCES `sa_academies`(`id`) ON DELETE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `sa_academy_contracts`",
];
