"""Add work_start_date + annual-leave balance fields to identity_persons. Revision ID: 163 Revises: 162 Create Date: 2026-05-14 Adds five columns the HR Tools / 年假计算器 feature needs: - ``work_start_date`` — 参加工作日期 (社会工龄 N 起点). Distinct from ``hire_date`` (司龄 S 起点) — first job ever, not first day at this company. Sourced from SuccessFactors ``EmpEmployment.originalStartDate`` via the full-employee sync; HR can override in the calculator. - ``annual_leave_carry_legal_days`` — 上年结转法定年假 - ``annual_leave_carry_welfare_days`` — 上年结转福利年假 - ``annual_leave_used_legal_days`` — 当年已休法定年假 - ``annual_leave_used_welfare_days`` — 当年已休福利年假 All five default NULL so older rows aren't synthetically zeroed. The calculator treats NULL as "HR must input"; sync writes when SF TimeAccount data is available, otherwise leaves NULL. DECIMAL(4,1) — supports the 0.5-step rounding rule with one decimal of precision; range covers the 15-day cap with headroom. """ from __future__ import annotations import sqlalchemy as sa from alembic import op revision = "163" down_revision = "162" branch_labels = None depends_on = None def upgrade() -> None: op.add_column( "identity_persons", sa.Column("work_start_date", sa.Date(), nullable=True), ) op.add_column( "identity_persons", sa.Column( "annual_leave_carry_legal_days", sa.Numeric(4, 1), nullable=True, ), ) op.add_column( "identity_persons", sa.Column( "annual_leave_carry_welfare_days", sa.Numeric(4, 1), nullable=True, ), ) op.add_column( "identity_persons", sa.Column( "annual_leave_used_legal_days", sa.Numeric(4, 1), nullable=True, ), ) op.add_column( "identity_persons", sa.Column( "annual_leave_used_welfare_days", sa.Numeric(4, 1), nullable=True, ), ) def downgrade() -> None: op.drop_column("identity_persons", "annual_leave_used_welfare_days") op.drop_column("identity_persons", "annual_leave_used_legal_days") op.drop_column("identity_persons", "annual_leave_carry_welfare_days") op.drop_column("identity_persons", "annual_leave_carry_legal_days") op.drop_column("identity_persons", "work_start_date")