"""Add Review table and relationships to Product and User table.

Revision ID: 6c9d78373dab
Revises: b8bcef009fb0
Create Date: 2019-01-08 17:19:41.947487

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '6c9d78373dab'
down_revision = 'b8bcef009fb0'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('review',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('rating', sa.Integer(), nullable=True),
    sa.Column('review', sa.Text(length=1000), nullable=True),
    sa.Column('comments', sa.Text(length=300), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_review_rating'), 'review', ['rating'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_review_rating'), table_name='review')
    op.drop_table('review')
    # ### end Alembic commands ###
