railyard/apps/mail/crates/mail-mta/migrations/0001_mta_warmup_tlsrpt.sql
caelum0x 173b60097d feat(mail): OCI relay pool, direct MTA (parked), inbound HTTPS ingest, Cloudflare inbound forwarder
- mail-oci: OCI Email Delivery client (signed REST), per-customer domain/DKIM/sender onboarding, suppression mirror, sending limits
- mail-mta: RelayPool transport with OCI primary, optional secondary, health/back-off/quota failover; direct MTA kept but off
- mail-inbound: DSN/ARF/DMARC/TLS-RPT parsing + HMAC-signed POST /inbound/raw ingest (no port 25)
- workers/inbound-forwarder: Cloudflare Email Routing worker forwarding raw mail over HTTPS

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 01:14:52 +03:00

47 lines
1.5 KiB
SQL

-- Outbound MTA state: IP warm-up ramp and TLS-RPT aggregation.
CREATE TABLE IF NOT EXISTS mta_warmup_ips (
ip TEXT PRIMARY KEY,
started_on DATE NOT NULL DEFAULT CURRENT_DATE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS mta_warmup_daily (
ip TEXT NOT NULL REFERENCES mta_warmup_ips(ip) ON DELETE CASCADE,
day DATE NOT NULL,
day_index INT NOT NULL,
cap BIGINT NOT NULL,
sent BIGINT NOT NULL DEFAULT 0,
delivered BIGINT NOT NULL DEFAULT 0,
deferred BIGINT NOT NULL DEFAULT 0,
bounced BIGINT NOT NULL DEFAULT 0,
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (ip, day)
);
CREATE TABLE IF NOT EXISTS mta_tls_failures (
id BIGSERIAL PRIMARY KEY,
domain TEXT NOT NULL,
policy_type TEXT NOT NULL,
result_type TEXT NOT NULL,
mx_host TEXT,
receiving_ip TEXT,
reason TEXT,
occurred_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS mta_tls_failures_domain_idx ON mta_tls_failures (domain, occurred_at);
CREATE TABLE IF NOT EXISTS mta_tls_reports (
id BIGSERIAL PRIMARY KEY,
domain TEXT NOT NULL,
report_id TEXT NOT NULL,
period_start TIMESTAMPTZ NOT NULL,
period_end TIMESTAMPTZ NOT NULL,
rua TEXT[] NOT NULL,
report JSONB NOT NULL,
status TEXT NOT NULL DEFAULT 'prepared',
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
sent_at TIMESTAMPTZ
);