ultisuite-backend/migrations/000008_outbox_hardening.up.sql
R3D347HR4Y 4eadb91a64 Enhance mail API with rate limiting, idempotency, and attachment management
- Added rate limiting for outbound email sends to prevent abuse, implemented in `internal/api/mail/sendguard`.
- Introduced idempotency key support for email sending to avoid duplicate submissions.
- Enhanced attachment handling with new limits and validation in `internal/api/mail/limits`.
- Updated outbox processing to include retry logic and circuit breaker for SMTP failures.
- Improved HTML sanitization for email content to enhance security.
- Added unit tests for new features, ensuring robust functionality and error handling.
- Updated configuration options in `.env.example` for new mail settings.
2026-05-22 17:19:16 +02:00

12 lines
414 B
SQL

ALTER TABLE outbox
ADD COLUMN IF NOT EXISTS idempotency_key TEXT NOT NULL DEFAULT '',
ADD COLUMN IF NOT EXISTS next_retry_at TIMESTAMPTZ;
CREATE UNIQUE INDEX IF NOT EXISTS idx_outbox_user_idempotency
ON outbox (user_id, idempotency_key)
WHERE idempotency_key <> '';
CREATE INDEX IF NOT EXISTS idx_outbox_queued_retry
ON outbox (status, next_retry_at, created_at)
WHERE status = 'queued';