"""seed admin and demo content

Revision ID: 20260711_0002
Revises: 20260711_0001
Create Date: 2026-07-11 14:05:00
"""

from typing import Sequence, Union

from alembic import op

revision: str = "20260711_0002"
down_revision: Union[str, None] = "20260711_0001"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # Demo users and CMS pages are seeded on API startup (app.main lifespan → run_seed)
    # after all schema migrations, including is_superuser (20260714_0003).
    pass


def downgrade() -> None:
    from sqlalchemy import delete

    from app.core.database import session_scope
    from app.modules.content.models import ContentPage
    from app.modules.users.models import User

    with session_scope() as db:
        db.execute(delete(ContentPage).where(ContentPage.slug.in_(["about", "privacy", "terms"])))
        db.execute(delete(User).where(User.email == "admin@compton.example"))
