From 555a5b364f9c4bac36abd06d5e4b2515d91cd5ae Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 27 Mar 2025 21:25:47 +0000 Subject: [PATCH] Add migration for Glory --- .../20250327_212530_9663cf8a_create_glory.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 alembic/versions/20250327_212530_9663cf8a_create_glory.py diff --git a/alembic/versions/20250327_212530_9663cf8a_create_glory.py b/alembic/versions/20250327_212530_9663cf8a_create_glory.py new file mode 100644 index 0000000..0c4a6d4 --- /dev/null +++ b/alembic/versions/20250327_212530_9663cf8a_create_glory.py @@ -0,0 +1,44 @@ +"""create glorys table + +Revision ID: a2b3c4d5e6f7 +Revises: +Create Date: 2024-01-01 12: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, unique=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('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'], unique=True) + +def downgrade(): + op.drop_index('ix_glorys_team_name', 'glorys') + op.drop_table('glorys') \ No newline at end of file