56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
"""Add Team.tz_timezone
|
|
|
|
Revision ID: ea359b0e46d7
|
|
Revises: 2b2f3ae2ec7f
|
|
Create Date: 2024-11-03 16:53:37.904012
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlalchemy_utc
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'ea359b0e46d7'
|
|
down_revision = '2b2f3ae2ec7f'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('players_teams_availability', schema=None) as batch_op:
|
|
batch_op.alter_column('start_time',
|
|
existing_type=sa.TIMESTAMP(),
|
|
type_=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True),
|
|
existing_nullable=False)
|
|
batch_op.alter_column('end_time',
|
|
existing_type=sa.TIMESTAMP(),
|
|
type_=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True),
|
|
existing_nullable=False)
|
|
|
|
with op.batch_alter_table('teams', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('tz_timezone', sa.String(length=31), nullable=False, default='Etc/UTC', server_default='0'))
|
|
batch_op.add_column(sa.Column('minute_offset', sa.SmallInteger(), nullable=False, default=0, server_default='0'))
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('teams', schema=None) as batch_op:
|
|
batch_op.drop_column('minute_offset')
|
|
batch_op.drop_column('tz_timezone')
|
|
|
|
with op.batch_alter_table('players_teams_availability', schema=None) as batch_op:
|
|
batch_op.alter_column('end_time',
|
|
existing_type=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True),
|
|
type_=sa.TIMESTAMP(),
|
|
existing_nullable=False)
|
|
batch_op.alter_column('start_time',
|
|
existing_type=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True),
|
|
type_=sa.TIMESTAMP(),
|
|
existing_nullable=False)
|
|
|
|
# ### end Alembic commands ###
|