"""empty message

Revision ID: 0a2e4c9070e5
Revises: 
Create Date: 2021-03-04 22:21:35.885399

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '0a2e4c9070e5'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('authority',
    sa.Column('aid', sa.Integer(), autoincrement=True, nullable=False, comment='权限id'),
    sa.Column('auth', sa.VARCHAR(length=20), nullable=True, comment='权限名'),
    sa.PrimaryKeyConstraint('aid')
    )
    op.create_table('lost_card',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='拾卡信息id'),
    sa.Column('create_time', sa.Integer(), nullable=False, comment='提交的时间戳'),
    sa.Column('edit_time', sa.Integer(), nullable=False, comment='修改时间'),
    sa.Column('uid', sa.Integer(), nullable=False, comment='失主学号'),
    sa.Column('name', sa.VARCHAR(length=20), nullable=False, comment='失主姓名'),
    sa.Column('contact', sa.VARCHAR(length=30), nullable=False, comment='联系方式'),
    sa.Column('place', sa.VARCHAR(length=30), nullable=False, comment='拾卡地点'),
    sa.Column('is_valid', sa.BOOLEAN(), nullable=False, comment='是否有效'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('roll',
    sa.Column('rid', sa.Integer(), autoincrement=True, nullable=False, comment='角色id'),
    sa.Column('dep', sa.VARCHAR(length=20), nullable=True, comment='角色部门'),
    sa.PrimaryKeyConstraint('rid')
    )
    op.create_table('user',
    sa.Column('uid', sa.Integer(), nullable=False, comment='学号'),
    sa.Column('network_username', sa.VARCHAR(length=20), nullable=False, comment='上网账号'),
    sa.Column('network_password', sa.VARCHAR(length=20), nullable=False, comment='上网密码'),
    sa.Column('card_password', sa.Integer(), nullable=False, comment='校园卡查询密码'),
    sa.Column('library_password', sa.Integer(), nullable=False, comment='图书馆借阅密码'),
    sa.Column('jwc_password', sa.VARCHAR(length=20), nullable=False, comment='教务处查询密码'),
    sa.PrimaryKeyConstraint('uid')
    )
    op.create_table('admin',
    sa.Column('username', sa.VARCHAR(length=20), nullable=False, comment='用户名'),
    sa.Column('password', sa.VARCHAR(length=20), nullable=True, comment='密码'),
    sa.Column('roll_id', sa.Integer(), nullable=True, comment='角色id'),
    sa.ForeignKeyConstraint(['roll_id'], ['roll.rid'], ),
    sa.PrimaryKeyConstraint('username')
    )
    op.create_table('advertisement',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='广告id'),
    sa.Column('create_time', sa.Integer(), nullable=False, comment='发布时间'),
    sa.Column('edit_time', sa.Integer(), nullable=False, comment='修改时间'),
    sa.Column('receiver', sa.Integer(), nullable=True),
    sa.Column('title', sa.VARCHAR(length=20), nullable=True, comment='广告标题'),
    sa.Column('author', sa.VARCHAR(length=20), nullable=True, comment='广告作者'),
    sa.Column('text', sa.TEXT(), nullable=True, comment='广告正文'),
    sa.Column('is_valid', sa.BOOLEAN(), nullable=False, comment='是否有效'),
    sa.ForeignKeyConstraint(['receiver'], ['roll.rid'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('notice',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='公告id'),
    sa.Column('create_time', sa.Integer(), nullable=False, comment='发布时间'),
    sa.Column('edit_time', sa.Integer(), nullable=False, comment='修改时间'),
    sa.Column('receiver', sa.Integer(), nullable=True),
    sa.Column('title', sa.VARCHAR(length=20), nullable=True, comment='标题'),
    sa.Column('author', sa.VARCHAR(length=20), nullable=True, comment='作者'),
    sa.Column('text', sa.TEXT(), nullable=True, comment='正文'),
    sa.Column('is_valid', sa.BOOLEAN(), nullable=False, comment='是否生效'),
    sa.ForeignKeyConstraint(['receiver'], ['roll.rid'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ro_au',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='角色权限关系id'),
    sa.Column('rid', sa.Integer(), nullable=True, comment='角色id'),
    sa.Column('aid', sa.Integer(), nullable=True, comment='权限id'),
    sa.ForeignKeyConstraint(['aid'], ['authority.aid'], ),
    sa.ForeignKeyConstraint(['rid'], ['roll.rid'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('ro_au')
    op.drop_table('notice')
    op.drop_table('advertisement')
    op.drop_table('admin')
    op.drop_table('user')
    op.drop_table('roll')
    op.drop_table('lost_card')
    op.drop_table('authority')
    # ### end Alembic commands ###
