<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `spouses` (
            `id`                 BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `member_id`          BIGINT UNSIGNED NOT NULL,
            `spouse_order`       INT UNSIGNED NOT NULL DEFAULT 1,
            `full_name_ar`       VARCHAR(200) NOT NULL,
            `full_name_en`       VARCHAR(200) NULL,
            `national_id`        VARCHAR(14) NULL,
            `passport_number`    VARCHAR(50) NULL,
            `date_of_birth`      DATE NOT NULL,
            `age_years`          INT UNSIGNED NULL,
            `age_months`         INT UNSIGNED NULL,
            `gender`             VARCHAR(10) NOT NULL,
            `nationality`        VARCHAR(100) NULL DEFAULT 'مصري',
            `religion`           VARCHAR(50) NULL,
            `qualification_id`   BIGINT UNSIGNED NULL,
            `occupation`         VARCHAR(200) NULL,
            `work_address`       TEXT NULL,
            `work_phone`         VARCHAR(20) NULL,
            `mobile`             VARCHAR(20) NULL,
            `marriage_date`      DATE NOT NULL,
            `join_date`          DATE NOT NULL,
            `classification`     VARCHAR(30) NOT NULL DEFAULT 'working',
            `addition_fee`       DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `fee_receipt_number` VARCHAR(50) NULL,
            `status`             VARCHAR(50) NOT NULL DEFAULT 'active',
            `photo_path`         VARCHAR(500) NULL,
            `is_archived`        TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at`        TIMESTAMP NULL DEFAULT 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,
            `updated_by`         BIGINT UNSIGNED NULL,
            INDEX `idx_spouses_member` (`member_id`),
            INDEX `idx_spouses_nid` (`national_id`),
            INDEX `idx_spouses_status` (`status`),
            INDEX `idx_spouses_archived` (`is_archived`),
            CONSTRAINT `fk_spouses_member` FOREIGN KEY (`member_id`) REFERENCES `members`(`id`),
            CONSTRAINT `fk_spouses_qualification` FOREIGN KEY (`qualification_id`) REFERENCES `qualifications`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `spouses`",
];