<filename>migrations/versions/ab2eacaace39_add_product_ingredient_table.py
"""add product_ingredient table

Revision ID: ab2eacaace39
Revises: <PASSWORD>
Create Date: 2021-03-26 15:11:08.938567

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ab2eacaace39'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('product_ingredient',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=False),
    sa.Column('ingredient_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['ingredient_id'], ['ingredient.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_product_ingredient_ingredient_id'), 'product_ingredient', ['ingredient_id'], unique=False)
    op.create_index(op.f('ix_product_ingredient_product_id'), 'product_ingredient', ['product_id'], unique=False)
    op.drop_table('product_ingredients')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('product_ingredients',
    sa.Column('product_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('ingredient_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['ingredient_id'], ['ingredient.id'], name='product_ingredients_ingredient_id_fkey'),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], name='product_ingredients_product_id_fkey'),
    sa.PrimaryKeyConstraint('product_id', 'ingredient_id', name='product_ingredients_pkey')
    )
    op.drop_index(op.f('ix_product_ingredient_product_id'), table_name='product_ingredient')
    op.drop_index(op.f('ix_product_ingredient_ingredient_id'), table_name='product_ingredient')
    op.drop_table('product_ingredient')
    # ### end Alembic commands ###

<filename>migrations/versions/ab2eacaace39_add_product_ingredient_table.py
"""add product_ingredient table

Revision ID: ab2eacaace39
Revises: <PASSWORD>
Create Date: 2021-03-26 15:11:08.938567

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ab2eacaace39'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('product_ingredient',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=False),
    sa.Column('ingredient_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['ingredient_id'], ['ingredient.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_product_ingredient_ingredient_id'), 'product_ingredient', ['ingredient_id'], unique=False)
    op.create_index(op.f('ix_product_ingredient_product_id'), 'product_ingredient', ['product_id'], unique=False)
    op.drop_table('product_ingredients')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('product_ingredients',
    sa.Column('product_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('ingredient_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['ingredient_id'], ['ingredient.id'], name='product_ingredients_ingredient_id_fkey'),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], name='product_ingredients_product_id_fkey'),
    sa.PrimaryKeyConstraint('product_id', 'ingredient_id', name='product_ingredients_pkey')
    )
    op.drop_index(op.f('ix_product_ingredient_product_id'), table_name='product_ingredient')
    op.drop_index(op.f('ix_product_ingredient_ingredient_id'), table_name='product_ingredient')
    op.drop_table('product_ingredient')
    # ### end Alembic commands ###

add product_ingredient table  Revision ID: ab2eacaace39 Revises: <PASSWORD> Create Date: 2021-03-26 15:11:08.938567 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###