Files
ShooterHub/migrations/versions/6818f37f4124_user_role_and_language.py
2026-03-20 15:41:55 +01:00

45 lines
1.3 KiB
Python

"""user_role_and_language
Revision ID: 6818f37f4124
Revises: bf96ceb7f076
Create Date: 2026-03-19 15:51:15.091825
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6818f37f4124'
down_revision = 'bf96ceb7f076'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.add_column(sa.Column('role', sa.String(length=20), nullable=True))
batch_op.add_column(sa.Column('language', sa.String(length=10), nullable=True))
op.execute("UPDATE users SET role = 'user' WHERE role IS NULL")
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.alter_column('role', nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.drop_column('language')
batch_op.drop_column('role')
op.execute("UPDATE users SET role = 'user' WHERE role IS NULL")
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.alter_column('role', nullable=False)
# ### end Alembic commands ###