<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `interviews` (
            `id`                       BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `member_id`                BIGINT UNSIGNED NOT NULL,
            `form_submission_id`       BIGINT UNSIGNED NULL,
            `scheduled_date`           DATE NOT NULL,
            `scheduled_time`           TIME NULL,
            `location`                 VARCHAR(200) NULL,
            `rescheduled_from`         DATE NULL,
            `reschedule_reason`        TEXT NULL,
            `reschedule_count`         INT UNSIGNED NOT NULL DEFAULT 0,
            `decision`                 VARCHAR(30) NOT NULL DEFAULT 'pending',
            `decision_notes`           TEXT NULL,
            `decision_date`            TIMESTAMP NULL DEFAULT NULL,
            `board_member_names`       TEXT NULL,
            `board_decision_reference` VARCHAR(100) NULL,
            `notification_sent`        TINYINT(1) NOT NULL DEFAULT 0,
            `notification_sent_at`     TIMESTAMP NULL DEFAULT NULL,
            `workflow_instance_id`     BIGINT UNSIGNED NULL,
            `status`                   VARCHAR(50) NOT NULL DEFAULT 'scheduled',
            `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_interviews_member` (`member_id`),
            INDEX `idx_interviews_date` (`scheduled_date`),
            INDEX `idx_interviews_decision` (`decision`),
            INDEX `idx_interviews_status` (`status`),
            CONSTRAINT `fk_interviews_member` FOREIGN KEY (`member_id`) REFERENCES `members`(`id`),
            CONSTRAINT `fk_interviews_form` FOREIGN KEY (`form_submission_id`) REFERENCES `form_submissions`(`id`) ON DELETE SET NULL,
            CONSTRAINT `fk_interviews_workflow` FOREIGN KEY (`workflow_instance_id`) REFERENCES `workflow_instances`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `interviews`",
];