<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `activity_pricing` (
            `id`                BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `pricing_type`      VARCHAR(30) NOT NULL COMMENT 'academy, discipline, facility',
            `reference_id`      BIGINT UNSIGNED NOT NULL COMMENT 'FK to academy/discipline/facility depending on pricing_type',
            `member_rate`       DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `nonmember_rate`    DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `member_rate_pm`    DECIMAL(15,2) NULL COMMENT 'PM rate for members (facilities)',
            `nonmember_rate_pm` DECIMAL(15,2) NULL COMMENT 'PM rate for non-members (facilities)',
            `effective_from`    DATE NOT NULL,
            `effective_to`      DATE 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,
            INDEX `idx_ap_type_ref` (`pricing_type`, `reference_id`),
            INDEX `idx_ap_effective` (`effective_from`, `effective_to`),
            INDEX `idx_ap_active` (`is_active`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `activity_pricing`",
];
