<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `packages` (
            `id`                     BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code`                   VARCHAR(30) NOT NULL,
            `name_ar`                VARCHAR(200) NOT NULL,
            `name_en`                VARCHAR(200) NULL,
            `description_ar`         TEXT NULL,
            `package_price_member`   DECIMAL(15,2) NOT NULL,
            `package_price_nonmember` DECIMAL(15,2) NOT NULL,
            `items_total_price`      DECIMAL(15,2) NOT NULL DEFAULT 0.00 COMMENT 'Sum of individual item prices',
            `active_from`            DATE NULL,
            `active_to`              DATE NULL,
            `is_active`              TINYINT(1) NOT NULL DEFAULT 1,
            `image_document_id`      BIGINT UNSIGNED NULL,
            `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,
            UNIQUE KEY `uq_packages_code` (`code`),
            INDEX `idx_packages_active_dates` (`is_active`, `active_from`, `active_to`),
            CONSTRAINT `fk_packages_image_document` FOREIGN KEY (`image_document_id`) REFERENCES `documents`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `packages`",
];
