<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `service_catalog` (
            `id`              BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `service_code`    VARCHAR(50) NOT NULL,
            `name_ar`         VARCHAR(200) NOT NULL,
            `name_en`         VARCHAR(200) NULL,
            `price_type`      VARCHAR(50) NOT NULL DEFAULT 'fixed',
            `base_amount`     DECIMAL(15,2) NULL,
            `percentage`      DECIMAL(5,2) NULL,
            `annual_amount`   DECIMAL(15,2) NULL,
            `currency`        VARCHAR(3) NOT NULL DEFAULT 'EGP',
            `applies_to`      VARCHAR(100) NULL,
            `branch_id`       BIGINT UNSIGNED NULL,
            `effective_from`  DATE NOT NULL,
            `effective_to`    DATE NULL DEFAULT NULL,
            `is_active`       TINYINT(1) NOT NULL DEFAULT 1,
            `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_service_catalog_code_branch` (`service_code`, `branch_id`),
            INDEX `idx_service_catalog_active` (`is_active`),
            CONSTRAINT `fk_service_catalog_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `service_catalog`",
];