<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `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,
    `minimum_revenue_guarantee` DECIMAL(15,2) NOT NULL DEFAULT 0.00,
    `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(15,2) NOT NULL DEFAULT 0.00,
    `deposit_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00,
    `deposit_status` VARCHAR(20) NOT NULL DEFAULT 'pending' COMMENT 'pending, paid, returned, forfeited',
    `settlement_day` TINYINT UNSIGNED NOT NULL DEFAULT 5,
    `grace_period_days` TINYINT UNSIGNED NOT NULL DEFAULT 7,
    `penalty_rate_pct` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
    `auto_renew` TINYINT(1) NOT NULL DEFAULT 0,
    `renewal_notice_days` INT UNSIGNED NOT NULL DEFAULT 30,
    `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,
    `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,
    `branch_id` BIGINT UNSIGNED NULL,
    UNIQUE KEY `uq_ac_number` (`contract_number`),
    INDEX `idx_ac_academy` (`academy_id`),
    INDEX `idx_ac_status` (`status`),
    INDEX `idx_ac_dates` (`start_date`, `end_date`),
    CONSTRAINT `fk_ac_academy` FOREIGN KEY (`academy_id`) REFERENCES `academies`(`id`) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `academy_contracts`",
];
