47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
|
"""empty message
|
||
|
|
||
|
Revision ID: 9d6b0ea04d2c
|
||
|
Revises: 5569d39a87cf
|
||
|
Create Date: 2024-01-07 11:34:58.903280
|
||
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = '9d6b0ea04d2c'
|
||
|
down_revision = '5569d39a87cf'
|
||
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||
|
batch_op.add_column(sa.Column('name', sa.String(length=100), nullable=True))
|
||
|
batch_op.add_column(sa.Column('email', sa.String(length=120), nullable=False))
|
||
|
batch_op.add_column(sa.Column('location', sa.String(length=100), nullable=True))
|
||
|
batch_op.alter_column('id',
|
||
|
existing_type=sa.INTEGER(),
|
||
|
type_=sa.String(length=36),
|
||
|
existing_nullable=False)
|
||
|
batch_op.create_unique_constraint('uq_user_email', ['email']) # Added constraint name here
|
||
|
batch_op.drop_column('username')
|
||
|
# ### end Alembic commands ###
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||
|
batch_op.add_column(sa.Column('username', sa.VARCHAR(length=80), nullable=False))
|
||
|
batch_op.drop_constraint('uq_user_email', type_='unique') # Updated constraint name here
|
||
|
batch_op.alter_column('id',
|
||
|
existing_type=sa.String(length=36),
|
||
|
type_=sa.INTEGER(),
|
||
|
existing_nullable=False)
|
||
|
batch_op.drop_column('location')
|
||
|
batch_op.drop_column('email')
|
||
|
batch_op.drop_column('name')
|
||
|
# ### end Alembic commands ###
|
||
|
|