"""empty message

Revision ID: f4c9dd33b371
Revises: 
Create Date: 2021-04-18 22:07:45.976269

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('orders', sa.Column('o_pid', sa.Integer(), nullable=False))
    op.add_column('orders', sa.Column('o_uid', sa.Integer(), nullable=False))
    op.add_column('orders', sa.Column('otime', sa.DateTime(), nullable=False))
    op.create_foreign_key(None, 'orders', 'products', ['o_pid'], ['pid'])
    op.create_foreign_key(None, 'orders', 'users', ['o_uid'], ['uid'])
    op.alter_column('products', 'name',
               existing_type=sa.TEXT(),
               nullable=False)
    op.create_unique_constraint(None, 'products', ['name'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'products', type_='unique')
    op.alter_column('products', 'name',
               existing_type=sa.TEXT(),
               nullable=True)
    op.drop_constraint(None, 'orders', type_='foreignkey')
    op.drop_constraint(None, 'orders', type_='foreignkey')
    op.drop_column('orders', 'otime')
    op.drop_column('orders', 'o_uid')
    op.drop_column('orders', 'o_pid')
    # ### end Alembic commands ###
