"""Phase 14.4 — Callback & Verification schema (additive)."""
from alembic import op
from app.core.database import Base
import app.models  # noqa: F401

revision = "0005_phase_144_callbacks"
down_revision = "0004_phase_143_requests"
branch_labels = None
depends_on = None

_CALLBACK_TABLES = (
    "payment_callback_logs",
    "payment_verification_attempts",
)


def upgrade():
    bind = op.get_bind()
    Base.metadata.create_all(bind=bind)


def downgrade():
    bind = op.get_bind()
    for name in reversed(_CALLBACK_TABLES):
        table = Base.metadata.tables.get(name)
        if table is not None:
            table.drop(bind=bind, checkfirst=True)
