CREATE TABLE IF NOT EXISTS mail_mailboxes (
    id                  BIGSERIAL PRIMARY KEY,
    tenant_slug         TEXT NOT NULL,
    name                TEXT NOT NULL,
    imap_host           TEXT NOT NULL,
    imap_port           INT NOT NULL DEFAULT 993,
    imap_username       TEXT NOT NULL,
    wrapped_password_dek BYTEA NOT NULL,
    encrypted_password  BYTEA NOT NULL,
    folder_selection    TEXT NOT NULL DEFAULT 'INBOX',
    interval_seconds    INT NOT NULL DEFAULT 300,
    created_at          TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at          TIMESTAMPTZ NOT NULL DEFAULT now(),
    UNIQUE (tenant_slug, name)
)
