51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
"""Update to submissionsampleassociation
|
|
|
|
Revision ID: 97392dda5436
|
|
Revises: e3f6770ef515
|
|
Create Date: 2024-01-25 09:10:04.384194
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '97392dda5436'
|
|
down_revision = 'e3f6770ef515'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=True))
|
|
batch_op.create_unique_constraint("submissionsampleassociation_id", ['id'])
|
|
|
|
with op.batch_alter_table('_wastewaterassociation', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('id', sa.INTEGER(), nullable=False))
|
|
# batch_op.drop_constraint("sample_id", type_='foreignkey')
|
|
# batch_op.drop_constraint("submission_id", type_='foreignkey')
|
|
batch_op.create_foreign_key("fk_subsampassoc_id", '_submissionsampleassociation', ['id'], ['id'])
|
|
# batch_op.drop_column('sample_id')
|
|
# batch_op.drop_column('submission_id')
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('_wastewaterassociation', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('submission_id', sa.INTEGER(), nullable=False))
|
|
batch_op.add_column(sa.Column('sample_id', sa.INTEGER(), nullable=False))
|
|
batch_op.drop_constraint(None, type_='foreignkey')
|
|
batch_op.create_foreign_key(None, '_submissionsampleassociation', ['submission_id'], ['submission_id'])
|
|
batch_op.create_foreign_key(None, '_submissionsampleassociation', ['sample_id'], ['sample_id'])
|
|
batch_op.drop_column('id')
|
|
|
|
with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
|
|
batch_op.drop_constraint(None, type_='unique')
|
|
batch_op.drop_column('id')
|
|
|
|
# ### end Alembic commands ###
|