"""Add day_override table. Lets a workspace correct the calendar cache (`app/data/swedish_calendar.json`) in either direction on a per-date basis: `is_working_day=false` means the workspace is off that day even though the calendar calls it a working day (e.g. a klämdag their employer gives off); `is_working_day=true` means the workspace must work despite the calendar (e.g. julafton is a normal workday there). See PLANNING_ENGINE task notes / app.services.allocation_service. Revision ID: 004 Revises: 003 Create Date: 2026-09-13 """ from __future__ import annotations from alembic import op revision: str = "004" down_revision: str | None = "003" branch_labels: str | None = None depends_on: str | None = None _UPGRADE_SQL = """ CREATE TABLE IF NOT EXISTS day_override ( id TEXT PRIMARY KEY, workspace_id TEXT NOT NULL, date DATE NOT NULL, is_working_day INTEGER NOT NULL, note TEXT, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, UNIQUE(workspace_id, date), FOREIGN KEY (workspace_id) REFERENCES workspace(id) ON DELETE CASCADE ); """ _DOWNGRADE_SQL = """ DROP TABLE IF EXISTS day_override; """ def upgrade() -> None: from sqlalchemy import text for stmt in [s.strip() for s in _UPGRADE_SQL.split(";") if s.strip()]: op.execute(text(stmt)) def downgrade() -> None: from sqlalchemy import text for stmt in [s.strip() for s in _DOWNGRADE_SQL.split(";") if s.strip()]: op.execute(text(stmt))