"""Phase 6.2 — Enterprise Sales Process Engine schema."""
from alembic import op
from app.core.database import Base
import app.models  # noqa: F401

revision = "0003_phase_62_sales_engine"
down_revision = "0002_phase_61_entities"
branch_labels = None
depends_on = None


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


def downgrade():
    tables = [
        "sales_audit",
        "sales_targets",
        "sales_goals",
        "sales_forecasts",
        "opportunity_win_loss",
        "win_loss_reasons",
        "win_loss_categories",
        "sales_playbook_assignments",
        "sales_playbook_steps",
        "sales_playbooks",
        "opportunity_competitors",
        "opportunity_contacts",
        "opportunity_products",
        "sales_stage_history",
        "sales_processes",
    ]
    for table in tables:
        op.drop_table(table)
