<?php
declare(strict_types=1);

return [
    'up' => "
CREATE TABLE `treasury_sessions` (
    `id`               BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `treasury_id`      BIGINT UNSIGNED NOT NULL,
    `cashier_id`       BIGINT UNSIGNED NOT NULL,
    `session_number`   VARCHAR(30) NOT NULL UNIQUE,
    `opened_at`        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `closed_at`        TIMESTAMP NULL,
    `opening_balance`  DECIMAL(14,2) NOT NULL DEFAULT 0.00,
    `closing_balance`  DECIMAL(14,2) NULL,
    `total_collected`  DECIMAL(14,2) NOT NULL DEFAULT 0.00,
    `total_receipts`   INT UNSIGNED NOT NULL DEFAULT 0,
    `status`           ENUM('open','closed','settled') NOT NULL DEFAULT 'open',
    `notes`            TEXT NULL,
    `created_at`       TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`       TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX `idx_tsessions_treasury` (`treasury_id`),
    INDEX `idx_tsessions_cashier` (`cashier_id`),
    INDEX `idx_tsessions_status` (`status`),
    CONSTRAINT `fk_tsessions_treasury` FOREIGN KEY (`treasury_id`) REFERENCES `treasuries`(`id`),
    CONSTRAINT `fk_tsessions_cashier` FOREIGN KEY (`cashier_id`) REFERENCES `employees`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
",
    'down' => "DROP TABLE IF EXISTS `treasury_sessions`",
];
