app/migrations/versions/2021_101111_2fbcad5527d7_.py

35 lines
907 B
Python
Raw Normal View History

2021-10-11 17:30:10 +08:00
"""empty message
Revision ID: 2fbcad5527d7
Revises: 0b1c9ea11aef
Create Date: 2021-10-11 11:17:46.750252
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2fbcad5527d7'
down_revision = '0b1c9ea11aef'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('alternative_id', sa.String(length=128), nullable=True))
op.create_unique_constraint(None, 'users', ['alternative_id'])
# set alternative_id to id
op.execute('UPDATE users SET alternative_id = id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'users', type_='unique')
op.drop_column('users', 'alternative_id')
# ### end Alembic commands ###