<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `daily_transactions` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `transaction_date`      DATE            NOT NULL,
            `journal_type_id`       BIGINT UNSIGNED NULL,
            `account_id`            BIGINT UNSIGNED NOT NULL,
            `cost_center_id`        BIGINT UNSIGNED NULL,
            `amount`                DECIMAL(18,2)   NOT NULL,
            `direction`             ENUM('debit','credit') NOT NULL,
            `description`           VARCHAR(500)    NULL,
            `document_number`       VARCHAR(50)     NULL,
            `currency`              VARCHAR(3)      NOT NULL DEFAULT 'EGP',
            `is_consolidated`       TINYINT(1)      NOT NULL DEFAULT 0,
            `consolidated_entry_id` BIGINT UNSIGNED NULL,
            `branch_id`             BIGINT UNSIGNED NULL,
            `created_at`            DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `created_by`            BIGINT UNSIGNED NULL,

            INDEX `idx_dt_date` (`transaction_date`),
            INDEX `idx_dt_consolidated` (`is_consolidated`),
            INDEX `idx_dt_type` (`journal_type_id`),
            FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts`(`id`),
            FOREIGN KEY (`journal_type_id`) REFERENCES `journal_types`(`id`),
            FOREIGN KEY (`consolidated_entry_id`) REFERENCES `journal_entries`(`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `daily_transactions`",
];
