"""Ajoute les journées travaillées pendant les vacances.

Revision ID: f1a5b6c7d8e9
Revises: e0f4a5b6c7d8
Create Date: 2026-08-14
"""

from alembic import op
import sqlalchemy as sa


revision = "f1a5b6c7d8e9"
down_revision = "e0f4a5b6c7d8"
branch_labels = None
depends_on = None


def upgrade():
    op.create_table(
        "closure_work_days",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("closure_id", sa.Integer(), nullable=False),
        sa.Column("work_date", sa.Date(), nullable=False),
        sa.Column("start_time", sa.Time(), nullable=False),
        sa.Column("end_time", sa.Time(), nullable=False),
        sa.Column("lunch_start", sa.Time(), nullable=True),
        sa.Column("lunch_end", sa.Time(), nullable=True),
        sa.Column("notes", sa.String(length=255), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(["closure_id"], ["college_closures.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("closure_id", "work_date", name="uq_closure_work_day"),
    )
    op.create_index("ix_closure_work_days_closure_id", "closure_work_days", ["closure_id"])
    op.create_index("ix_closure_work_days_work_date", "closure_work_days", ["work_date"])


def downgrade():
    op.drop_index("ix_closure_work_days_work_date", table_name="closure_work_days")
    op.drop_index("ix_closure_work_days_closure_id", table_name="closure_work_days")
    op.drop_table("closure_work_days")
