"""Vacation entitlement: pro-rata + part-time config (agent-11 PR2)

Revision ID: 0036
Revises: 0035
Create Date: 2026-06-23

- users.entry_date / exit_date (Basis für anteilige Urlaubsberechnung, Zwölftel)
- companies.vacation_default_days (Vollzeit-Grundurlaub für neue Konten)
- companies.vacation_prorate_first_year (anteilig im Ein-/Austrittsjahr)
- companies.vacation_from_schedule (Teilzeit-Anspruch aus WorkSchedule ableiten)

Resturlaub-Verfall bleibt in companies.settings (carryover_expires_month/day),
wird in PR2 nur scharf geschaltet (effektiv verfügbarer Saldo) – keine Spalte nötig.
"""
from alembic import op

revision = "0036"
down_revision = "0035"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS entry_date DATE")
    op.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS exit_date DATE")
    op.execute("ALTER TABLE companies ADD COLUMN IF NOT EXISTS vacation_default_days INTEGER NOT NULL DEFAULT 30")
    op.execute("ALTER TABLE companies ADD COLUMN IF NOT EXISTS vacation_prorate_first_year BOOLEAN NOT NULL DEFAULT TRUE")
    op.execute("ALTER TABLE companies ADD COLUMN IF NOT EXISTS vacation_from_schedule BOOLEAN NOT NULL DEFAULT FALSE")


def downgrade() -> None:
    op.execute("ALTER TABLE companies DROP COLUMN IF EXISTS vacation_from_schedule")
    op.execute("ALTER TABLE companies DROP COLUMN IF EXISTS vacation_prorate_first_year")
    op.execute("ALTER TABLE companies DROP COLUMN IF EXISTS vacation_default_days")
    op.execute("ALTER TABLE users DROP COLUMN IF EXISTS exit_date")
    op.execute("ALTER TABLE users DROP COLUMN IF EXISTS entry_date")
