<?php
declare(strict_types=1);

return [
    'up' => "
ALTER TABLE sa_bookings ADD COLUMN participant_mode ENUM('full','partial','passes') NOT NULL DEFAULT 'passes' AFTER participant_count;
ALTER TABLE sa_bookings ADD COLUMN passes_total INT UNSIGNED NOT NULL DEFAULT 0 AFTER participant_mode;
ALTER TABLE sa_bookings ADD COLUMN passes_used INT UNSIGNED NOT NULL DEFAULT 0 AFTER passes_total;
CREATE TABLE sa_booking_passes (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    booking_id BIGINT UNSIGNED NOT NULL,
    pass_number VARCHAR(30) NOT NULL,
    status ENUM('issued','used','expired','cancelled') NOT NULL DEFAULT 'issued',
    used_at DATETIME NULL,
    used_by_name VARCHAR(200) NULL,
    gate_employee_id BIGINT UNSIGNED NULL,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    INDEX idx_bp_booking (booking_id),
    UNIQUE KEY uq_bp_number (pass_number)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
",
    'down' => "
DROP TABLE IF EXISTS sa_booking_passes;
ALTER TABLE sa_bookings DROP COLUMN passes_used;
ALTER TABLE sa_bookings DROP COLUMN passes_total;
ALTER TABLE sa_bookings DROP COLUMN participant_mode
",
];
