feat: agent-02-kiosk Phase 1 - NFC UID migration + session service
- Migration 0025: kiosk_nfc_uid column on users table with partial unique index per company - User model: kiosk_nfc_uid field after personnel_number - New service: kiosk_session_service.py (Redis-based 15min sessions) - New core module: app/core/redis.py (sync Redis client with ping-test) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Add kiosk_nfc_uid to users table
|
||||
|
||||
Revision ID: 0025
|
||||
Revises: 0024
|
||||
Create Date: 2026-05-24
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "0025"
|
||||
down_revision = "0024"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# NFC-UID für Kiosk-Login (optional, eindeutig pro Firma über partial unique index)
|
||||
op.add_column("users", sa.Column("kiosk_nfc_uid", sa.String(64), nullable=True))
|
||||
op.create_index(
|
||||
"ix_users_kiosk_nfc_uid",
|
||||
"users",
|
||||
["kiosk_nfc_uid"],
|
||||
unique=False, # Uniqueness nur innerhalb company → partial index
|
||||
)
|
||||
# Partial unique index: NFC-UID eindeutig innerhalb einer Firma
|
||||
op.execute("""
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_users_nfc_uid_per_company
|
||||
ON users (company_id, kiosk_nfc_uid)
|
||||
WHERE kiosk_nfc_uid IS NOT NULL
|
||||
""")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute("DROP INDEX IF EXISTS uq_users_nfc_uid_per_company")
|
||||
op.drop_index("ix_users_kiosk_nfc_uid", table_name="users")
|
||||
op.drop_column("users", "kiosk_nfc_uid")
|
||||
Reference in New Issue
Block a user