<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `rule_versions` (
            `id`              BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `rule_id`         BIGINT UNSIGNED NOT NULL,
            `version_number`  INT UNSIGNED NOT NULL,
            `old_value_json`  JSON NULL,
            `new_value_json`  JSON NOT NULL,
            `changed_by`      BIGINT UNSIGNED NULL,
            `changed_at`      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `change_reason`   TEXT NULL,
            INDEX `idx_rule_versions_rule` (`rule_id`),
            CONSTRAINT `fk_rule_versions_rule` FOREIGN KEY (`rule_id`) REFERENCES `business_rules`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `rule_versions`",
];