"""Align imported lot and room data with the application schema.

Revision ID: b7a1c2d3e4f5
Revises: 6fb96f39feb4
Create Date: 2026-08-14
"""

from alembic import op
import sqlalchemy as sa


revision = "b7a1c2d3e4f5"
down_revision = "6fb96f39feb4"
branch_labels = None
depends_on = None


def upgrade():
    # L'application cree encore les tables au demarrage pour les nouvelles
    # installations. Ces instructions MariaDB restent donc idempotentes.
    op.execute("ALTER TABLE lots MODIFY name VARCHAR(500) NOT NULL")
    op.execute("ALTER TABLE lot_tasks MODIFY periodicite VARCHAR(200) NULL")
    op.execute("ALTER TABLE rooms ADD COLUMN IF NOT EXISTS zone VARCHAR(100) NULL")


def downgrade():
    op.execute("ALTER TABLE rooms DROP COLUMN IF EXISTS zone")
    op.execute("ALTER TABLE lot_tasks MODIFY periodicite VARCHAR(50) NULL")
    op.execute("ALTER TABLE lots MODIFY name VARCHAR(100) NOT NULL")
