<?php
declare(strict_types=1);
return [
    'up' => "CREATE TABLE `alert_rules` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `code` VARCHAR(50) NOT NULL UNIQUE,
    `name_ar` VARCHAR(300) NOT NULL,
    `category` VARCHAR(50) NOT NULL COMMENT 'medical, contracts, financial, attendance, capacity, subscriptions, safety',
    `trigger_type` VARCHAR(30) NOT NULL COMMENT 'threshold, expiry, schedule',
    `trigger_config_json` JSON NOT NULL,
    `notification_channels` VARCHAR(200) NOT NULL DEFAULT 'system' COMMENT 'comma-separated: system, sms, email',
    `recipient_roles_json` JSON NULL,
    `is_active` TINYINT(1) NOT NULL DEFAULT 1,
    `last_triggered_at` TIMESTAMP NULL,
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX `idx_alert_category` (`category`),
    INDEX `idx_alert_active` (`is_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `alert_rules`",
];
