"""add order model

Revision ID: b4f158b20249
Revises: 42e3ec619f32
Create Date: 2018-12-09 20:10:54.529146

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b4f158b20249'
down_revision = '42e3ec619f32'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('orders',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('status', sa.String(length=16), nullable=True),
    sa.Column('remark', sa.String(length=64), nullable=True),
    sa.Column('total_cost', sa.Float(), nullable=True),
    sa.Column('owner_id', sa.Integer(), nullable=True),
    sa.Column('restaurant_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['restaurant_id'], ['restaurants.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('order_items', sa.Column('order_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'order_items', 'orders', ['order_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'order_items', type_='foreignkey')
    op.drop_column('order_items', 'order_id')
    op.drop_table('orders')
    # ### end Alembic commands ###
