Files
aitsc/migrations/versions/89df165acd11_add_admin_user_table.py

42 lines
1.4 KiB
Python

"""Add admin user table
Revision ID: 89df165acd11
Revises: e1ec7bb6c8ec
Create Date: 2025-08-29 21:47:36.122009
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '89df165acd11'
down_revision = 'e1ec7bb6c8ec'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('admin_user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=50), nullable=False, comment='用户名'),
sa.Column('password_hash', sa.String(length=128), nullable=False, comment='密码哈希'),
sa.Column('email', sa.String(length=100), nullable=False, comment='邮箱'),
sa.Column('role', sa.String(length=20), nullable=False, comment='角色'),
sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否激活'),
sa.Column('last_login', sa.DateTime(), nullable=True, comment='最后登录时间'),
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email'),
sa.UniqueConstraint('username')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('admin_user')
# ### end Alembic commands ###