|
| 1 | +"""empty message |
| 2 | +
|
| 3 | +Revision ID: ea100e6c099d |
| 4 | +Revises: 6231e10bfdc0 |
| 5 | +Create Date: 2023-03-26 10:38:06.503533 |
| 6 | +
|
| 7 | +""" |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | + |
| 11 | + |
| 12 | +# revision identifiers, used by Alembic. |
| 13 | +revision = 'ea100e6c099d' |
| 14 | +down_revision = '6231e10bfdc0' |
| 15 | +branch_labels = None |
| 16 | +depends_on = None |
| 17 | + |
| 18 | + |
| 19 | +def upgrade(): |
| 20 | + # ### commands auto generated by Alembic - please adjust! ### |
| 21 | + op.create_table('category_rel', |
| 22 | + sa.Column('id', sa.Integer(), nullable=False), |
| 23 | + sa.Column('inventory_id', sa.Integer(), nullable=False), |
| 24 | + sa.Column('category_id', sa.Integer(), nullable=False), |
| 25 | + sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ), |
| 26 | + sa.ForeignKeyConstraint(['inventory_id'], ['inventory.id'], ), |
| 27 | + sa.PrimaryKeyConstraint('id', 'inventory_id', 'category_id') |
| 28 | + ) |
| 29 | + op.create_table('sub_category_rel', |
| 30 | + sa.Column('id', sa.Integer(), nullable=False), |
| 31 | + sa.Column('inventory_id', sa.Integer(), nullable=False), |
| 32 | + sa.Column('sub_category_id', sa.Integer(), nullable=False), |
| 33 | + sa.ForeignKeyConstraint(['inventory_id'], ['inventory.id'], ), |
| 34 | + sa.ForeignKeyConstraint(['sub_category_id'], ['sub_categories.id'], ), |
| 35 | + sa.PrimaryKeyConstraint('id', 'inventory_id', 'sub_category_id') |
| 36 | + ) |
| 37 | + op.drop_table('sub_categories_rel') |
| 38 | + op.drop_table('categories_rel') |
| 39 | + with op.batch_alter_table('inventory_delivery_rel', schema=None) as batch_op: |
| 40 | + batch_op.add_column(sa.Column('id', sa.Integer(), nullable=False)) |
| 41 | + |
| 42 | + # ### end Alembic commands ### |
| 43 | + |
| 44 | + |
| 45 | +def downgrade(): |
| 46 | + # ### commands auto generated by Alembic - please adjust! ### |
| 47 | + with op.batch_alter_table('inventory_delivery_rel', schema=None) as batch_op: |
| 48 | + batch_op.drop_column('id') |
| 49 | + |
| 50 | + op.create_table('categories_rel', |
| 51 | + sa.Column('inventory_id', sa.INTEGER(), autoincrement=False, nullable=False), |
| 52 | + sa.Column('categories_id', sa.INTEGER(), autoincrement=False, nullable=False), |
| 53 | + sa.ForeignKeyConstraint(['categories_id'], ['categories.id'], name='categories_rel_categories_id_fkey'), |
| 54 | + sa.ForeignKeyConstraint(['inventory_id'], ['inventory.id'], name='categories_rel_inventory_id_fkey'), |
| 55 | + sa.PrimaryKeyConstraint('inventory_id', 'categories_id', name='categories_rel_pkey') |
| 56 | + ) |
| 57 | + op.create_table('sub_categories_rel', |
| 58 | + sa.Column('inventory_id', sa.INTEGER(), autoincrement=False, nullable=False), |
| 59 | + sa.Column('sub_categories_id', sa.INTEGER(), autoincrement=False, nullable=False), |
| 60 | + sa.ForeignKeyConstraint(['inventory_id'], ['inventory.id'], name='sub_categories_rel_inventory_id_fkey'), |
| 61 | + sa.ForeignKeyConstraint(['sub_categories_id'], ['sub_categories.id'], name='sub_categories_rel_sub_categories_id_fkey'), |
| 62 | + sa.PrimaryKeyConstraint('inventory_id', 'sub_categories_id', name='sub_categories_rel_pkey') |
| 63 | + ) |
| 64 | + op.drop_table('sub_category_rel') |
| 65 | + op.drop_table('category_rel') |
| 66 | + # ### end Alembic commands ### |
0 commit comments