"""Autorise les interventions sans équipement.

Revision ID: a8b2c3d4e5f6
Revises: f7a1b2c3d4e5
"""
from alembic import op
import sqlalchemy as sa

revision = "a8b2c3d4e5f6"
down_revision = "f7a1b2c3d4e5"
branch_labels = None
depends_on = None

def upgrade():
    op.alter_column("interventions", "equipment_id", existing_type=sa.Integer(), nullable=True)

def downgrade():
    op.execute("DELETE FROM interventions WHERE equipment_id IS NULL")
    op.alter_column("interventions", "equipment_id", existing_type=sa.Integer(), nullable=False)
