<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE `sa_locker_rentals` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `rental_number` VARCHAR(30) NOT NULL,
    `locker_id` BIGINT UNSIGNED NOT NULL,
    `player_id` BIGINT UNSIGNED NOT NULL,
    `rental_type` ENUM('monthly','6_months','yearly') NOT NULL,
    `start_date` DATE NOT NULL,
    `end_date` DATE NOT NULL,
    `amount` DECIMAL(15,2) NOT NULL,
    `payment_status` ENUM('unpaid','paid','partial') NOT NULL DEFAULT 'unpaid',
    `payment_id` BIGINT UNSIGNED NULL,
    `receipt_id` BIGINT UNSIGNED NULL,
    `receipt_number` VARCHAR(50) NULL,
    `status` VARCHAR(30) NOT NULL DEFAULT 'active',
    `grace_started_at` DATE NULL,
    `evicted_at` DATE NULL,
    `eviction_reason` TEXT NULL,
    `eviction_by` BIGINT UNSIGNED NULL,
    `renewed_from_id` BIGINT UNSIGNED 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,
    UNIQUE KEY `uq_sa_lr_number` (`rental_number`),
    INDEX `idx_sa_lr_locker` (`locker_id`),
    INDEX `idx_sa_lr_player` (`player_id`),
    INDEX `idx_sa_lr_status` (`status`),
    INDEX `idx_sa_lr_dates` (`start_date`, `end_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",

    'down' => "DROP TABLE IF EXISTS `sa_locker_rentals`;",
];
