<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `sms_log` (
            `id`                   BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `member_id`            BIGINT UNSIGNED NULL,
            `phone_number`         VARCHAR(20) NOT NULL,
            `template_id`          BIGINT UNSIGNED NULL,
            `message_text`         TEXT NOT NULL,
            `message_type`         VARCHAR(20) NOT NULL DEFAULT 'single',
            `status`               VARCHAR(30) NOT NULL DEFAULT 'queued',
            `provider_message_id`  VARCHAR(200) NULL,
            `provider_response`    TEXT NULL,
            `cost`                 DECIMAL(10,4) NULL,
            `retry_count`          INT UNSIGNED NOT NULL DEFAULT 0,
            `max_retries`          INT UNSIGNED NOT NULL DEFAULT 3,
            `sent_at`              TIMESTAMP NULL DEFAULT NULL,
            `delivered_at`         TIMESTAMP NULL DEFAULT NULL,
            `failed_at`            TIMESTAMP NULL DEFAULT NULL,
            `failure_reason`       TEXT NULL,
            `sent_by`              BIGINT UNSIGNED NULL,
            `created_at`           TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            INDEX `idx_sms_log_member` (`member_id`),
            INDEX `idx_sms_log_phone` (`phone_number`),
            INDEX `idx_sms_log_status` (`status`),
            INDEX `idx_sms_log_date` (`created_at`),
            INDEX `idx_sms_log_template` (`template_id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `sms_log`",
];