"""add_order_model

Revision ID: 2aaf6e830251
Revises: 0b4fdf2ee7b1
Create Date: 2018-09-14 23:28:52.758057

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2aaf6e830251'
down_revision = '0b4fdf2ee7b1'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('order_info',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('order_code', sa.String(length=32), nullable=True),
    sa.Column('shop_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('order_address', sa.String(length=128), nullable=True),
    sa.Column('order_price', sa.Float(), nullable=True),
    sa.Column('order_status', sa.Integer(), nullable=True),
    sa.Column('created_time', sa.DateTime(), nullable=True),
    sa.Column('trade_sn', sa.String(length=128), nullable=True),
    sa.ForeignKeyConstraint(['shop_id'], ['seller_shop.pub_id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['buyer_user.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('order_code')
    )
    op.create_table('order_goods',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('order_id', sa.Integer(), nullable=True),
    sa.Column('goods_id', sa.Integer(), nullable=True),
    sa.Column('goods_name', sa.String(length=64), nullable=True),
    sa.Column('goods_image', sa.String(length=128), nullable=True),
    sa.Column('goods_price', sa.Float(), nullable=True),
    sa.Column('amount', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['order_id'], ['order_info.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('order_goods')
    op.drop_table('order_info')
    # ### end Alembic commands ###
