Первоначальная версия VidConf

This commit is contained in:
2026-07-23 01:04:01 +03:00
commit 896455381a
335 changed files with 61527 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
"""teams
Справочник команд и привязка пользователя к команде:
- `teams` — id/name (уникально)/created_at;
- `users.team_id` — необязательная ссылка на команду, `ON DELETE SET NULL`
(удаление команды не удаляет пользователей, только снимает привязку).
Revision ID: 9d37822e4513
Revises: 5970bf64fc43
Create Date: 2026-07-18 03:00:27.636900
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '9d37822e4513'
down_revision: Union[str, Sequence[str], None] = '5970bf64fc43'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
op.create_table(
'teams',
sa.Column('id', sa.UUID(), server_default=sa.text('gen_random_uuid()'), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column(
'created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'),
nullable=False,
),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name'),
)
op.add_column('users', sa.Column('team_id', sa.UUID(), nullable=True))
op.create_foreign_key(
'fk_users_team_id_teams', 'users', 'teams', ['team_id'], ['id'], ondelete='SET NULL'
)
def downgrade() -> None:
"""Downgrade schema."""
op.drop_constraint('fk_users_team_id_teams', 'users', type_='foreignkey')
op.drop_column('users', 'team_id')
op.drop_table('teams')