Add migration for Glory
This commit is contained in:
parent
8dbd7300a3
commit
ad23c48989
46
alembic/versions/20250327_212310_6d9c1171_create_glory.py
Normal file
46
alembic/versions/20250327_212310_6d9c1171_create_glory.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
"""create glorys table
|
||||||
|
|
||||||
|
Revision ID: a2b3c4d5e6f7
|
||||||
|
Revises:
|
||||||
|
Create Date: 2024-01-09 10:00:00.000000
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
# revision identifiers
|
||||||
|
revision = 'a2b3c4d5e6f7'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'glorys',
|
||||||
|
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
|
||||||
|
sa.Column('team_name', sa.String(), nullable=False, index=True),
|
||||||
|
sa.Column('league', sa.String(), nullable=False),
|
||||||
|
sa.Column('points', sa.Integer(), default=0),
|
||||||
|
sa.Column('matches_played', sa.Integer(), default=0),
|
||||||
|
sa.Column('wins', sa.Integer(), default=0),
|
||||||
|
sa.Column('draws', sa.Integer(), default=0),
|
||||||
|
sa.Column('losses', sa.Integer(), default=0),
|
||||||
|
sa.Column('goals_for', sa.Integer(), default=0),
|
||||||
|
sa.Column('goals_against', sa.Integer(), default=0),
|
||||||
|
sa.Column('goal_difference', sa.Integer(), default=0),
|
||||||
|
sa.Column('position', sa.Integer()),
|
||||||
|
sa.Column('is_active', sa.Boolean(), default=True),
|
||||||
|
sa.Column('season', sa.String(), nullable=False),
|
||||||
|
sa.Column('coach', sa.String()),
|
||||||
|
sa.Column('home_stadium', sa.String()),
|
||||||
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index('ix_glorys_team_name', 'glorys', ['team_name'])
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index('ix_glorys_team_name', 'glorys')
|
||||||
|
op.drop_table('glorys')
|
Loading…
x
Reference in New Issue
Block a user