47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""Add password column to user
|
|
|
|
Revision ID: d4406f5b12f7
|
|
Revises:
|
|
Create Date: 2025-04-28 21:26:37.430823
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'd4406f5b12f7'
|
|
down_revision = None
|
|
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('password', sa.String(length=512), nullable=False, server_default="changeme"))
|
|
batch_op.add_column(sa.Column('is_active', sa.Boolean(), nullable=True))
|
|
batch_op.add_column(sa.Column('role', sa.String(length=20), nullable=True))
|
|
batch_op.drop_column('last_login')
|
|
batch_op.drop_column('bio')
|
|
batch_op.drop_column('password_hash')
|
|
batch_op.drop_column('is_admin')
|
|
batch_op.drop_column('avatar')
|
|
|
|
# ### 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('avatar', sa.VARCHAR(length=200), nullable=True))
|
|
batch_op.add_column(sa.Column('is_admin', sa.BOOLEAN(), nullable=True))
|
|
batch_op.add_column(sa.Column('password_hash', sa.VARCHAR(length=128), nullable=True))
|
|
batch_op.add_column(sa.Column('bio', sa.TEXT(), nullable=True))
|
|
batch_op.add_column(sa.Column('last_login', sa.DATETIME(), nullable=True))
|
|
batch_op.drop_column('role')
|
|
batch_op.drop_column('is_active')
|
|
batch_op.drop_column('password')
|
|
|
|
# ### end Alembic commands ###
|