Initial commit – TimeMaster Zeiterfassung & HR-Tool
Stand: agent-06 (Audit-Log), agent-05 (Krankmeldung), agent-07 Phase 1 (Personalnummer), Busylight-Pull-Integration, TOTP/2FA, Abwesenheiten, Zeiterfassung, Kiosk-Grundgerüst. Migrations 0001–0023 deployed auf 192.168.1.137 + .164. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
"""add personnel_number to users + company config
|
||||
|
||||
Revision ID: 0020
|
||||
Revises: 0019
|
||||
Create Date: 2026-05-05
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "0020"
|
||||
down_revision = "0019"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# users.personnel_number with format constraint
|
||||
op.add_column(
|
||||
"users",
|
||||
sa.Column("personnel_number", sa.String(length=50), nullable=True),
|
||||
)
|
||||
op.create_check_constraint(
|
||||
"ck_users_personnel_number_digits",
|
||||
"users",
|
||||
"personnel_number IS NULL OR personnel_number ~ '^[0-9]+$'",
|
||||
)
|
||||
# Partial unique index per company (NULLs allowed, reserved on deactivation)
|
||||
op.create_index(
|
||||
"ix_users_company_personnel_number",
|
||||
"users",
|
||||
["company_id", "personnel_number"],
|
||||
unique=True,
|
||||
postgresql_where=sa.text("personnel_number IS NOT NULL"),
|
||||
)
|
||||
|
||||
# companies config
|
||||
op.add_column(
|
||||
"companies",
|
||||
sa.Column(
|
||||
"personnel_number_required",
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default="false",
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"companies",
|
||||
sa.Column(
|
||||
"personnel_number_mode",
|
||||
sa.String(length=10),
|
||||
nullable=False,
|
||||
server_default="manual",
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"companies",
|
||||
sa.Column(
|
||||
"personnel_number_next",
|
||||
sa.Integer(),
|
||||
nullable=False,
|
||||
server_default="1",
|
||||
),
|
||||
)
|
||||
|
||||
# ldap_configs.attr_personnel_number (optional mapping)
|
||||
op.add_column(
|
||||
"ldap_configs",
|
||||
sa.Column("attr_personnel_number", sa.String(length=100), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("ldap_configs", "attr_personnel_number")
|
||||
op.drop_column("companies", "personnel_number_next")
|
||||
op.drop_column("companies", "personnel_number_mode")
|
||||
op.drop_column("companies", "personnel_number_required")
|
||||
op.drop_index("ix_users_company_personnel_number", table_name="users")
|
||||
op.drop_constraint("ck_users_personnel_number_digits", "users", type_="check")
|
||||
op.drop_column("users", "personnel_number")
|
||||
Reference in New Issue
Block a user