"""Phase 12.3 — Table Service & Reservations schema."""
from alembic import op
import sqlalchemy as sa
from app.core.database import Base
import app.models  # noqa: F401

revision = "0004_phase_123_table_svc"
down_revision = "0003_phase_122_qr_menu_ordering"
branch_labels = None
depends_on = None


def upgrade():
    bind = op.get_bind()
    # Create new table-service / reservation tables from metadata (additive)
    Base.metadata.create_all(bind=bind)


def downgrade():
    bind = op.get_bind()
    for table in (
        "waitlist_entries",
        "service_requests",
        "table_assignments",
        "reservations",
    ):
        if sa.inspect(bind).has_table(table):
            op.drop_table(table)
