"""drop cross-domain FK constraints (events → cart)

Merge three existing heads and remove:
- calendar_entries.order_id FK → orders.id
- tickets.order_id FK → orders.id

Columns are kept as plain integers.

Revision ID: j0h8e4f6g7
Revises: c3d4e5f6a7b8, i9g7d3e5f6, g7e5b1c3d4f8
Create Date: 2026-02-14
"""
from alembic import op
import sqlalchemy as sa

revision = 'j0h8e4f6g7'
down_revision = ('c3d4e5f6a7b8', 'i9g7d3e5f6', 'g7e5b1c3d4f8')
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.drop_constraint(
        'fk_calendar_entries_order_id',
        'calendar_entries',
        type_='foreignkey',
    )
    op.drop_constraint(
        'tickets_order_id_fkey',
        'tickets',
        type_='foreignkey',
    )


def downgrade() -> None:
    op.create_foreign_key(
        'fk_calendar_entries_order_id',
        'calendar_entries',
        'orders',
        ['order_id'],
        ['id'],
        ondelete='SET NULL',
    )
    op.create_foreign_key(
        'tickets_order_id_fkey',
        'tickets',
        'orders',
        ['order_id'],
        ['id'],
        ondelete='SET NULL',
    )
