<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `foreign_member_details` (
            `id`                     BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `member_id`              BIGINT UNSIGNED NOT NULL,
            `passport_number`        VARCHAR(50) NOT NULL,
            `issuing_country_id`     BIGINT UNSIGNED NOT NULL,
            `nationality_country_id` BIGINT UNSIGNED NOT NULL,
            `passport_issue_date`    DATE NOT NULL,
            `passport_expiry_date`   DATE NOT NULL,
            `place_of_birth`         VARCHAR(200) NULL,
            `fee_amount_usd`         DECIMAL(15,2) NOT NULL,
            `exchange_rate`          DECIMAL(15,4) NULL,
            `fee_amount_egp`         DECIMAL(15,2) NULL,
            `fee_receipt_number`     VARCHAR(50) NULL,
            `status`                 VARCHAR(50) NOT NULL DEFAULT 'active',
            `notes`                  TEXT 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_foreign_member` (`member_id`),
            INDEX `idx_foreign_passport` (`passport_number`),
            INDEX `idx_foreign_expiry` (`passport_expiry_date`),
            CONSTRAINT `fk_foreign_member` FOREIGN KEY (`member_id`) REFERENCES `members`(`id`),
            CONSTRAINT `fk_foreign_issuing_country` FOREIGN KEY (`issuing_country_id`) REFERENCES `countries`(`id`),
            CONSTRAINT `fk_foreign_nationality_country` FOREIGN KEY (`nationality_country_id`) REFERENCES `countries`(`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `foreign_member_details`",
];