first kanban-view integration for client groups

This commit is contained in:
2025-06-27 08:22:01 +00:00
parent 9b78db8223
commit f176c40a02
15 changed files with 751 additions and 380 deletions

View File

@@ -0,0 +1,57 @@
"""Add client_groups table and group_id to clients
Revision ID: 8a45ec34f84d
Revises: c1178d5fa549
Create Date: 2025-06-26 18:40:10.988281
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '8a45ec34f84d'
down_revision: Union[str, None] = 'c1178d5fa549'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# 1. Neue Tabelle anlegen
op.create_table(
'client_groups',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(timezone=True),
server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
# 2. Gruppe "Nicht zugeordnet" mit id=0 anlegen
op.execute(
"INSERT INTO client_groups (id, name, is_active) VALUES (0, 'Nicht zugeordnet', true)")
# 3. Spalte group_id mit Default 0 hinzufügen
op.add_column('clients', sa.Column('group_id', sa.Integer(),
nullable=False, server_default='0'))
# 4. Für alle bestehenden Clients group_id auf 0 setzen (optional, falls Daten vorhanden)
op.execute("UPDATE clients SET group_id = 0 WHERE group_id IS NULL")
# 5. Foreign Key Constraint setzen
op.create_foreign_key(None, 'clients', 'client_groups', [
'group_id'], ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'clients', type_='foreignkey')
op.drop_column('clients', 'group_id')
op.drop_table('client_groups')
# ### end Alembic commands ###