<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `journal_types` (
            `id`                BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code`              VARCHAR(10)     NOT NULL COMMENT 'Unique short code e.g. GEN, RCV, PAY',
            `name_ar`           VARCHAR(100)    NOT NULL,
            `name_en`           VARCHAR(100)    NOT NULL,
            `short_name_ar`     VARCHAR(20)     NULL,
            `short_name_en`     VARCHAR(20)     NULL,
            `numbering_method`  ENUM('yearly','monthly') NOT NULL DEFAULT 'yearly',
            `number_prefix`     VARCHAR(10)     NULL COMMENT 'Prefix for entry numbers e.g. RCV-',
            `number_length`     TINYINT UNSIGNED NOT NULL DEFAULT 6,
            `is_auto_generated` TINYINT(1)      NOT NULL DEFAULT 0 COMMENT 'System-generated entries only',
            `is_default`        TINYINT(1)      NOT NULL DEFAULT 0 COMMENT 'Default journal type for manual entries',
            `is_active`         TINYINT(1)      NOT NULL DEFAULT 1,
            `created_at`        DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at`        DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

            UNIQUE INDEX `idx_jt_code` (`code`),
            INDEX `idx_jt_active` (`is_active`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `journal_types`",
];
