availabili.tf/backend/migrations/versions/c23b1c32e89a_add_playerinfo...

61 lines
2.4 KiB
Python
Raw Normal View History

2024-10-23 16:14:47 -07:00
"""Add PlayerInfo tables and others
Revision ID: c23b1c32e89a
Revises: dcdb8fccde69
Create Date: 2024-10-23 15:54:26.432098
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'c23b1c32e89a'
down_revision: Union[str, None] = 'dcdb8fccde69'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('teams',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('team_name', sa.String(length=63), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('playerinfo',
sa.Column('player_id', sa.BigInteger(), nullable=False),
sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ),
sa.PrimaryKeyConstraint('player_id')
)
op.create_table('playerinfo_teams',
sa.Column('playerinfo_id', sa.BigInteger(), nullable=False),
sa.Column('team_id', sa.Integer(), nullable=False),
sa.Column('team_role', sa.Enum('PLAYER', 'COACH_MENTOR', 'TEAM_CAPTAIN', name='teamrole'), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['playerinfo_id'], ['playerinfo.player_id'], ),
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
sa.PrimaryKeyConstraint('playerinfo_id', 'team_id')
)
op.create_table('playerrole',
sa.Column('playerinfo_id', sa.BigInteger(), nullable=False),
sa.Column('team_id', sa.Integer(), nullable=False),
sa.Column('class_role', sa.Enum('P_SCOUT', 'F_SCOUT', 'SCOUT', 'P_SOLLY', 'ROAMER', 'SOLDIER', 'PYRO', 'DEMO', 'HEAVY', 'ENGIE', 'MEDIC', 'SNIPER', 'SPY', name='classrole'), nullable=False),
sa.Column('main', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['playerinfo_id'], ['playerinfo_teams.playerinfo_id'], ),
sa.ForeignKeyConstraint(['team_id'], ['playerinfo_teams.team_id'], ),
sa.PrimaryKeyConstraint('playerinfo_id', 'team_id', 'class_role')
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('playerrole')
op.drop_table('playerinfo_teams')
op.drop_table('playerinfo')
op.drop_table('teams')
# ### end Alembic commands ###