62 lines
2.5 KiB
Python
62 lines
2.5 KiB
Python
"""Initial migration
|
|
|
|
Revision ID: ce676db8c655
|
|
Revises:
|
|
Create Date: 2024-10-28 17:42:13.639729
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'ce676db8c655'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('players',
|
|
sa.Column('steam_id', sa.BigInteger(), nullable=False),
|
|
sa.Column('username', sa.String(length=63), nullable=False),
|
|
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
|
sa.PrimaryKeyConstraint('steam_id')
|
|
)
|
|
op.create_table('teams',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('team_name', sa.String(length=63), nullable=False),
|
|
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('team_name')
|
|
)
|
|
op.create_table('players_teams',
|
|
sa.Column('player_id', sa.BigInteger(), nullable=False),
|
|
sa.Column('team_id', sa.Integer(), nullable=False),
|
|
sa.Column('team_role', sa.Enum('Player', 'CoachMentor', name='teamrole'), nullable=False),
|
|
sa.Column('playtime', sa.Interval(), nullable=False),
|
|
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
|
sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ),
|
|
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
|
sa.PrimaryKeyConstraint('player_id', 'team_id')
|
|
)
|
|
op.create_table('players_teams_roles',
|
|
sa.Column('player_id', sa.Integer(), nullable=False),
|
|
sa.Column('team_id', sa.Integer(), nullable=False),
|
|
sa.Column('role', sa.Enum('Unknown', 'Scout', 'PocketScout', 'FlankScout', 'Soldier', 'PocketSoldier', 'Roamer', 'Pyro', 'Demoman', 'HeavyWeapons', 'Engineer', 'Medic', 'Sniper', 'Spy', name='role'), nullable=False),
|
|
sa.Column('is_main', sa.Boolean(), nullable=False),
|
|
sa.ForeignKeyConstraint(['player_id', 'team_id'], ['players_teams.player_id', 'players_teams.team_id'], ),
|
|
sa.PrimaryKeyConstraint('player_id', 'team_id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('players_teams_roles')
|
|
op.drop_table('players_teams')
|
|
op.drop_table('teams')
|
|
op.drop_table('players')
|
|
# ### end Alembic commands ###
|