"""per-event invitation messages

Revision ID: c4a1e7f92b18
Revises: b7d2f8e19c34
Create Date: 2026-08-15 21:40:00.000000

Adds the greeting override column to `event`, mirroring the one already on `wedding`
(design D9). Purely additive and reversible: an empty map means "inherit", which is the
correct state for every event that already exists, so nothing is backfilled and the upgrade
cannot lose data.

The downgrade drops customisations along with the column, and every event falls back to the
wedding-wide message — which is exactly what it did before this revision, so nothing a guest
sees becomes empty.
"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

revision: str = "c4a1e7f92b18"
down_revision: str | None = "b7d2f8e19c34"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.add_column(
        "event",
        sa.Column(
            "invitation_messages",
            postgresql.JSONB(astext_type=sa.Text()),
            nullable=False,
            server_default="{}",
        ),
    )


def downgrade() -> None:
    op.drop_column("event", "invitation_messages")
