<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `children` (
            `id`                       BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `member_id`                BIGINT UNSIGNED NOT NULL,
            `child_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,
            `birth_certificate_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,
            `relationship`             VARCHAR(30) NOT NULL DEFAULT 'son',
            `school_faculty`           VARCHAR(200) NULL,
            `nationality`              VARCHAR(100) NULL DEFAULT 'مصري',
            `classification`           VARCHAR(50) NOT NULL DEFAULT 'included',
            `addition_fee`             DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `fee_receipt_number`       VARCHAR(50) NULL,
            `status`                   VARCHAR(50) NOT NULL DEFAULT 'active',
            `is_frozen`                TINYINT(1) NOT NULL DEFAULT 0,
            `frozen_at`                TIMESTAMP NULL DEFAULT NULL,
            `frozen_reason`            VARCHAR(200) NULL,
            `photo_path`               VARCHAR(500) NULL,
            `remarks`                  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_children_member` (`member_id`),
            INDEX `idx_children_nid` (`national_id`),
            INDEX `idx_children_status` (`status`),
            INDEX `idx_children_classification` (`classification`),
            INDEX `idx_children_frozen` (`is_frozen`),
            INDEX `idx_children_dob` (`date_of_birth`),
            INDEX `idx_children_archived` (`is_archived`),
            CONSTRAINT `fk_children_member` FOREIGN KEY (`member_id`) REFERENCES `members`(`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `children`",
];