<?php
declare(strict_types=1);

return [
    'up' => "
CREATE TABLE `treasury_custody_log` (
    `id`                BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `treasury_id`       BIGINT UNSIGNED NOT NULL,
    `employee_id`       BIGINT UNSIGNED NOT NULL,
    `action`            ENUM('collection','settlement_out','settlement_in','deposit','deposit_confirmed','void_reversal') NOT NULL,
    `amount`            DECIMAL(14,2) NOT NULL,
    `balance_after`     DECIMAL(14,2) NOT NULL,
    `reference_type`    VARCHAR(30) NULL,
    `reference_id`      BIGINT UNSIGNED NULL,
    `description_ar`    VARCHAR(255) NULL,
    `created_at`        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX `idx_custody_treasury` (`treasury_id`),
    INDEX `idx_custody_employee` (`employee_id`),
    INDEX `idx_custody_created` (`created_at`),
    CONSTRAINT `fk_custody_treasury` FOREIGN KEY (`treasury_id`) REFERENCES `treasuries`(`id`),
    CONSTRAINT `fk_custody_employee` FOREIGN KEY (`employee_id`) REFERENCES `employees`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
",
    'down' => "DROP TABLE IF EXISTS `treasury_custody_log`",
];
