
from alembic import op
import sqlalchemy as sa



revision = '04dacedb6803'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('chinese_library_classification_base',
    sa.Column('base_type', sa.String(length=256), nullable=False),
    sa.Column('id', sa.String(length=2), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('base_type')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('name', sa.String(length=16), nullable=False),
    sa.Column('authority', sa.Integer(), nullable=False),
    sa.Column('_a_passwd', sa.String(length=256), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('books',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('book_name', sa.String(length=256), nullable=False),
    sa.Column('Author', sa.String(length=256), nullable=False),
    sa.Column('publishing_house', sa.String(length=256), nullable=False),
    sa.Column('book_classification', sa.String(length=10), nullable=True),
    sa.Column('all_quantity', sa.Integer(), nullable=True),
    sa.Column('now_quantity', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['book_classification'], ['chinese_library_classification_base.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('book_name')
    )
    op.create_table('book_borrow',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('book_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )



def downgrade():

    op.drop_table('book_borrow')
    op.drop_table('books')
    op.drop_table('user')
    op.drop_table('chinese_library_classification_base')


