Files
timemaster/backend/migrations/versions/0012_caldav_template_and_kuerzel.py
sysops 1fedd683e0 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>
2026-05-23 20:03:27 +02:00

55 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""caldav name_template + users.kuerzel
Revision ID: 0012
Revises: 0011_caldav_name_format
Create Date: 2026-03-28
"""
from alembic import op
import sqlalchemy as sa
revision = '0012_caldav_template_and_kuerzel'
down_revision = '0011_caldav_name_format'
branch_labels = None
depends_on = None
# Mapping alter Festwert → neues Template
_MIGRATION_MAP = {
'full': '$vorname $nachname $typ',
'short': '$vorname_short. $nachname $typ',
'initials': '$kuerzel $typ',
'type_only': '$typ',
}
_DEFAULT = '$vorname $nachname $typ'
def upgrade() -> None:
# 1. Neue Spalte name_template hinzufügen
op.add_column('caldav_company_configs', sa.Column(
'name_template', sa.Text(), nullable=False,
server_default=_DEFAULT,
))
# 2. Bestehende Werte aus name_format migrieren
for old_val, new_val in _MIGRATION_MAP.items():
op.execute(
f"UPDATE caldav_company_configs "
f"SET name_template = '{new_val}' "
f"WHERE name_format = '{old_val}'"
)
# 3. Alte Spalte entfernen
op.drop_column('caldav_company_configs', 'name_format')
# 4. Kürzel-Spalte zu users hinzufügen
op.add_column('users', sa.Column(
'kuerzel', sa.String(20), nullable=True
))
def downgrade() -> None:
op.add_column('caldav_company_configs', sa.Column(
'name_format', sa.String(20), nullable=False, server_default='full'
))
op.drop_column('caldav_company_configs', 'name_template')
op.drop_column('users', 'kuerzel')