<?php

return <<<'SQL'
CREATE TABLE notification_messages (
    id CHAR(36) NOT NULL PRIMARY KEY,
    tenant_id CHAR(36) NOT NULL,
    title VARCHAR(180) NOT NULL,
    message TEXT NOT NULL,
    channel VARCHAR(50) NOT NULL DEFAULT 'email',
    recipient_scope VARCHAR(50) NOT NULL DEFAULT 'all',
    recipient_count INT NOT NULL DEFAULT 0,
    status VARCHAR(50) NOT NULL DEFAULT 'draft',
    scheduled_at DATETIME NULL,
    sent_at DATETIME NULL,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    INDEX notification_messages_tenant_status_idx (tenant_id, status, created_at),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);
SQL;
