Added Postgres support.

This commit is contained in:
lwark
2024-07-25 08:41:44 -05:00
parent 54e1e55804
commit 4bc5e08ac6
32 changed files with 579 additions and 1030 deletions

View File

@@ -1,8 +1,8 @@
"""First Commit
"""rebuild 20240723
Revision ID: e3f6770ef515
Revision ID: 0746f7e2c10e
Revises:
Create Date: 2024-01-22 14:01:02.958292
Create Date: 2024-07-23 14:08:37.436400
"""
from alembic import op
@@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e3f6770ef515'
revision = '0746f7e2c10e'
down_revision = None
branch_labels = None
depends_on = None
@@ -25,6 +25,12 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('submitter_id')
)
op.create_table('_configitem',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('key', sa.String(length=32), nullable=True),
sa.Column('value', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_contact',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=True),
@@ -66,9 +72,10 @@ def upgrade() -> None:
op.create_table('_process',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=True),
sa.PrimaryKeyConstraint('id')
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('_reagenttype',
op.create_table('_reagentrole',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=True),
sa.Column('eol_ext', sa.Interval(), nullable=True),
@@ -78,10 +85,17 @@ def upgrade() -> None:
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=True),
sa.Column('info_map', sa.JSON(), nullable=True),
sa.Column('template_file', sa.BLOB(), nullable=True),
sa.Column('defaults', sa.JSON(), nullable=True),
sa.Column('template_file', sa.LargeBinary(), nullable=True),
sa.Column('sample_map', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('_tiprole',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_bacterialculturesample',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('organism', sa.String(length=64), nullable=True),
@@ -117,17 +131,17 @@ def upgrade() -> None:
sa.ForeignKeyConstraint(['equipmentrole_id'], ['_equipmentrole.id'], ),
sa.ForeignKeyConstraint(['process_id'], ['_process.id'], )
)
op.create_table('_kittypereagenttypeassociation',
sa.Column('reagent_types_id', sa.INTEGER(), nullable=False),
op.create_table('_kittypereagentroleassociation',
sa.Column('reagent_roles_id', sa.INTEGER(), nullable=False),
sa.Column('kits_id', sa.INTEGER(), nullable=False),
sa.Column('submission_type_id', sa.INTEGER(), nullable=False),
sa.Column('uses', sa.JSON(), nullable=True),
sa.Column('required', sa.INTEGER(), nullable=True),
sa.Column('last_used', sa.String(length=32), nullable=True),
sa.ForeignKeyConstraint(['kits_id'], ['_kittype.id'], ),
sa.ForeignKeyConstraint(['reagent_types_id'], ['_reagenttype.id'], ),
sa.ForeignKeyConstraint(['reagent_roles_id'], ['_reagentrole.id'], ),
sa.ForeignKeyConstraint(['submission_type_id'], ['_submissiontype.id'], ),
sa.PrimaryKeyConstraint('reagent_types_id', 'kits_id', 'submission_type_id')
sa.PrimaryKeyConstraint('reagent_roles_id', 'kits_id', 'submission_type_id')
)
op.create_table('_kittypes_processes',
sa.Column('process_id', sa.INTEGER(), nullable=True),
@@ -141,13 +155,19 @@ def upgrade() -> None:
sa.ForeignKeyConstraint(['contact_id'], ['_contact.id'], ),
sa.ForeignKeyConstraint(['org_id'], ['_organization.id'], )
)
op.create_table('_process_tiprole',
sa.Column('process_id', sa.INTEGER(), nullable=True),
sa.Column('tiprole_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['process_id'], ['_process.id'], ),
sa.ForeignKeyConstraint(['tiprole_id'], ['_tiprole.id'], )
)
op.create_table('_reagent',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('type_id', sa.INTEGER(), nullable=True),
sa.Column('role_id', sa.INTEGER(), nullable=True),
sa.Column('name', sa.String(length=64), nullable=True),
sa.Column('lot', sa.String(length=64), nullable=True),
sa.Column('expiry', sa.TIMESTAMP(), nullable=True),
sa.ForeignKeyConstraint(['type_id'], ['_reagenttype.id'], name='fk_reagent_type_id', ondelete='SET NULL'),
sa.ForeignKeyConstraint(['role_id'], ['_reagentrole.id'], name='fk_reagent_role_id', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_submissiontypeequipmentroleassociation',
@@ -175,6 +195,23 @@ def upgrade() -> None:
sa.ForeignKeyConstraint(['equipmentroles_id'], ['_submissiontype.id'], ),
sa.ForeignKeyConstraint(['process_id'], ['_process.id'], )
)
op.create_table('_submissiontypetiproleassociation',
sa.Column('tiprole_id', sa.INTEGER(), nullable=False),
sa.Column('submissiontype_id', sa.INTEGER(), nullable=False),
sa.Column('uses', sa.JSON(), nullable=True),
sa.Column('static', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['submissiontype_id'], ['_submissiontype.id'], ),
sa.ForeignKeyConstraint(['tiprole_id'], ['_tiprole.id'], ),
sa.PrimaryKeyConstraint('tiprole_id', 'submissiontype_id')
)
op.create_table('_tips',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('role_id', sa.INTEGER(), nullable=True),
sa.Column('name', sa.String(length=64), nullable=True),
sa.Column('lot', sa.String(length=64), nullable=True),
sa.ForeignKeyConstraint(['role_id'], ['_tiprole.id'], name='fk_tip_role_id', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_wastewatersample',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('ww_processing_num', sa.String(length=64), nullable=True),
@@ -197,13 +234,15 @@ def upgrade() -> None:
sa.Column('extraction_kit_id', sa.INTEGER(), nullable=True),
sa.Column('submission_type_name', sa.String(), nullable=True),
sa.Column('technician', sa.String(length=64), nullable=True),
sa.Column('reagents_id', sa.String(), nullable=True),
sa.Column('reagents_id', sa.INTEGER(), nullable=True),
sa.Column('extraction_info', sa.JSON(), nullable=True),
sa.Column('pcr_info', sa.JSON(), nullable=True),
sa.Column('run_cost', sa.FLOAT(precision=2), nullable=True),
sa.Column('uploaded_by', sa.String(length=32), nullable=True),
sa.Column('signed_by', sa.String(length=32), nullable=True),
sa.Column('comment', sa.JSON(), nullable=True),
sa.Column('submission_category', sa.String(length=64), nullable=True),
sa.Column('cost_centre', sa.String(length=64), nullable=True),
sa.Column('contact_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['contact_id'], ['_contact.id'], name='fk_BS_contact_id', ondelete='SET NULL'),
sa.ForeignKeyConstraint(['extraction_kit_id'], ['_kittype.id'], name='fk_BS_extkit_id', ondelete='SET NULL'),
sa.ForeignKeyConstraint(['reagents_id'], ['_reagent.id'], name='fk_BS_reagents_id', ondelete='SET NULL'),
sa.ForeignKeyConstraint(['submission_type_name'], ['_submissiontype.name'], name='fk_BS_subtype_name', ondelete='SET NULL'),
@@ -212,11 +251,23 @@ def upgrade() -> None:
sa.UniqueConstraint('rsl_plate_num'),
sa.UniqueConstraint('submitter_plate_num')
)
op.create_table('_reagenttypes_reagents',
op.create_table('_equipment_tips',
sa.Column('equipment_id', sa.INTEGER(), nullable=True),
sa.Column('tips_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['equipment_id'], ['_equipment.id'], ),
sa.ForeignKeyConstraint(['tips_id'], ['_tips.id'], )
)
op.create_table('_reagentroles_reagents',
sa.Column('reagent_id', sa.INTEGER(), nullable=True),
sa.Column('reagenttype_id', sa.INTEGER(), nullable=True),
sa.Column('reagentrole_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['reagent_id'], ['_reagent.id'], ),
sa.ForeignKeyConstraint(['reagenttype_id'], ['_reagenttype.id'], )
sa.ForeignKeyConstraint(['reagentrole_id'], ['_reagentrole.id'], )
)
op.create_table('_tiproles_tips',
sa.Column('tiprole_id', sa.INTEGER(), nullable=True),
sa.Column('tips_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['tiprole_id'], ['_tiprole.id'], ),
sa.ForeignKeyConstraint(['tips_id'], ['_tips.id'], )
)
op.create_table('_bacterialculture',
sa.Column('id', sa.INTEGER(), nullable=False),
@@ -225,7 +276,7 @@ def upgrade() -> None:
)
op.create_table('_control',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('parent_id', sa.String(), nullable=True),
sa.Column('parent_id', sa.INTEGER(), nullable=True),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('submitted_date', sa.TIMESTAMP(), nullable=True),
sa.Column('contains', sa.JSON(), nullable=True),
@@ -264,19 +315,31 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint('reagent_id', 'submission_id')
)
op.create_table('_submissionsampleassociation',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('sample_id', sa.INTEGER(), nullable=False),
sa.Column('submission_id', sa.INTEGER(), nullable=False),
sa.Column('row', sa.INTEGER(), nullable=False),
sa.Column('column', sa.INTEGER(), nullable=False),
sa.Column('submission_rank', sa.INTEGER(), nullable=False),
sa.Column('base_sub_type', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['sample_id'], ['_basicsample.id'], ),
sa.ForeignKeyConstraint(['submission_id'], ['_basicsubmission.id'], ),
sa.PrimaryKeyConstraint('submission_id', 'row', 'column')
sa.PrimaryKeyConstraint('submission_id', 'row', 'column'),
sa.UniqueConstraint('id')
)
op.create_table('_submissiontipsassociation',
sa.Column('tip_id', sa.INTEGER(), nullable=False),
sa.Column('submission_id', sa.INTEGER(), nullable=False),
sa.Column('role_name', sa.String(length=32), nullable=False),
sa.ForeignKeyConstraint(['submission_id'], ['_basicsubmission.id'], ),
sa.ForeignKeyConstraint(['tip_id'], ['_tips.id'], ),
sa.PrimaryKeyConstraint('tip_id', 'submission_id', 'role_name')
)
op.create_table('_wastewater',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('ext_technician', sa.String(length=64), nullable=True),
sa.Column('pcr_technician', sa.String(length=64), nullable=True),
sa.Column('pcr_info', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['id'], ['_basicsubmission.id'], ),
sa.PrimaryKeyConstraint('id')
)
@@ -284,20 +347,36 @@ def upgrade() -> None:
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('artic_technician', sa.String(length=64), nullable=True),
sa.Column('dna_core_submission_number', sa.String(length=64), nullable=True),
sa.Column('pcr_info', sa.JSON(), nullable=True),
sa.Column('gel_image', sa.String(length=64), nullable=True),
sa.Column('gel_info', sa.JSON(), nullable=True),
sa.Column('gel_controls', sa.JSON(), nullable=True),
sa.Column('source_plates', sa.JSON(), nullable=True),
sa.Column('artic_date', sa.TIMESTAMP(), nullable=True),
sa.Column('ngs_date', sa.TIMESTAMP(), nullable=True),
sa.Column('gel_date', sa.TIMESTAMP(), nullable=True),
sa.Column('gel_barcode', sa.String(length=16), nullable=True),
sa.ForeignKeyConstraint(['id'], ['_basicsubmission.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_wastewaterarticassociation',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('source_plate', sa.String(length=16), nullable=True),
sa.Column('source_plate_number', sa.INTEGER(), nullable=True),
sa.Column('source_well', sa.String(length=8), nullable=True),
sa.Column('ct', sa.String(length=8), nullable=True),
sa.ForeignKeyConstraint(['id'], ['_submissionsampleassociation.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_wastewaterassociation',
sa.Column('sample_id', sa.INTEGER(), nullable=False),
sa.Column('submission_id', sa.INTEGER(), nullable=False),
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('ct_n1', sa.FLOAT(precision=2), nullable=True),
sa.Column('ct_n2', sa.FLOAT(precision=2), nullable=True),
sa.Column('n1_status', sa.String(length=32), nullable=True),
sa.Column('n2_status', sa.String(length=32), nullable=True),
sa.Column('pcr_results', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['sample_id'], ['_submissionsampleassociation.sample_id'], ),
sa.ForeignKeyConstraint(['submission_id'], ['_submissionsampleassociation.submission_id'], ),
sa.PrimaryKeyConstraint('sample_id', 'submission_id')
sa.ForeignKeyConstraint(['id'], ['_submissionsampleassociation.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
@@ -305,30 +384,38 @@ def upgrade() -> None:
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('_wastewaterassociation')
op.drop_table('_wastewaterarticassociation')
op.drop_table('_wastewaterartic')
op.drop_table('_wastewater')
op.drop_table('_submissiontipsassociation')
op.drop_table('_submissionsampleassociation')
op.drop_table('_submissionreagentassociation')
op.drop_table('_submissionequipmentassociation')
op.drop_table('_control')
op.drop_table('_bacterialculture')
op.drop_table('_reagenttypes_reagents')
op.drop_table('_tiproles_tips')
op.drop_table('_reagentroles_reagents')
op.drop_table('_equipment_tips')
op.drop_table('_basicsubmission')
op.drop_table('_wastewatersample')
op.drop_table('_tips')
op.drop_table('_submissiontypetiproleassociation')
op.drop_table('_submissiontypes_processes')
op.drop_table('_submissiontypekittypeassociation')
op.drop_table('_submissiontypeequipmentroleassociation')
op.drop_table('_reagent')
op.drop_table('_process_tiprole')
op.drop_table('_orgs_contacts')
op.drop_table('_kittypes_processes')
op.drop_table('_kittypereagenttypeassociation')
op.drop_table('_kittypereagentroleassociation')
op.drop_table('_equipmentroles_processes')
op.drop_table('_equipmentroles_equipment')
op.drop_table('_equipment_processes')
op.drop_table('_discount')
op.drop_table('_bacterialculturesample')
op.drop_table('_tiprole')
op.drop_table('_submissiontype')
op.drop_table('_reagenttype')
op.drop_table('_reagentrole')
op.drop_table('_process')
op.drop_table('_organization')
op.drop_table('_kittype')
@@ -336,5 +423,6 @@ def downgrade() -> None:
op.drop_table('_equipment')
op.drop_table('_controltype')
op.drop_table('_contact')
op.drop_table('_configitem')
op.drop_table('_basicsample')
# ### end Alembic commands ###

View File

@@ -1,54 +0,0 @@
"""Made WastewaterArticAssociation
Revision ID: 16b20d4368e6
Revises: d2b094cfa308
Create Date: 2024-06-13 12:16:48.385516
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '16b20d4368e6'
down_revision = 'd2b094cfa308'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('_wastewaterarticassociation',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('source_plate', sa.String(length=16), nullable=True),
sa.Column('source_plate_number', sa.INTEGER(), nullable=True),
sa.Column('source_well', sa.String(length=8), nullable=True),
sa.Column('ct', sa.String(length=8), nullable=True),
sa.ForeignKeyConstraint(['id'], ['_submissionsampleassociation.id'], ),
sa.PrimaryKeyConstraint('id')
)
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.create_unique_constraint(None, ['id'])
#
# with op.batch_alter_table('_submissiontipsassociation', schema=None) as batch_op:
# batch_op.alter_column('role_name',
# existing_type=sa.INTEGER(),
# type_=sa.String(length=32),
# existing_nullable=True)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_submissiontipsassociation', schema=None) as batch_op:
batch_op.alter_column('role_name',
existing_type=sa.String(length=32),
type_=sa.INTEGER(),
existing_nullable=True)
with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='unique')
op.drop_table('_wastewaterarticassociation')
# ### end Alembic commands ###

View File

@@ -1,51 +0,0 @@
"""adding cost centre storage to basicsubmission
Revision ID: 6d2a357860ef
Revises: e6647bd661d9
Create Date: 2024-04-24 13:01:14.923814
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6d2a357860ef'
down_revision = 'e6647bd661d9'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# op.drop_table('_alembic_tmp__submissionsampleassociation')
with op.batch_alter_table('_basicsubmission', schema=None) as batch_op:
batch_op.add_column(sa.Column('cost_centre', sa.String(length=64), nullable=True))
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.create_unique_constraint(None, ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
with op.batch_alter_table('_basicsubmission', schema=None) as batch_op:
batch_op.drop_column('used_cost_centre')
op.create_table('_alembic_tmp__submissionsampleassociation',
sa.Column('sample_id', sa.INTEGER(), nullable=False),
sa.Column('submission_id', sa.INTEGER(), nullable=False),
sa.Column('row', sa.INTEGER(), nullable=False),
sa.Column('column', sa.INTEGER(), nullable=False),
sa.Column('base_sub_type', sa.VARCHAR(), nullable=True),
sa.Column('id', sa.INTEGER(), server_default=sa.text('1'), nullable=False),
sa.ForeignKeyConstraint(['sample_id'], ['_basicsample.id'], ),
sa.ForeignKeyConstraint(['submission_id'], ['_basicsubmission.id'], ),
sa.PrimaryKeyConstraint('submission_id', 'row', 'column'),
sa.UniqueConstraint('id', name='ssa_id')
)
# ### end Alembic commands ###

View File

@@ -1,34 +0,0 @@
"""adding gel image, info. Again
Revision ID: 70426df72f80
Revises: c4201b0ea9fe
Create Date: 2024-01-30 08:47:22.809841
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '70426df72f80'
down_revision = 'c4201b0ea9fe'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.add_column(sa.Column('gel_image', sa.String(length=64), nullable=True))
batch_op.add_column(sa.Column('gel_info', sa.JSON(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.drop_column('gel_info')
batch_op.drop_column('gel_image')
# ### end Alembic commands ###

View File

@@ -1,38 +0,0 @@
"""tweaking submission sample association
Revision ID: 70d5a751f579
Revises: 97392dda5436
Create Date: 2024-01-25 13:39:34.163501
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '70d5a751f579'
down_revision = '97392dda5436'
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.alter_column('id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.create_unique_constraint("ssa_id_unique", ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
batch_op.drop_constraint("ssa_id_unique", type_='unique')
batch_op.alter_column('id',
existing_type=sa.INTEGER(),
nullable=False)
# ### end Alembic commands ###

View File

@@ -1,72 +0,0 @@
"""Adding fields to Artic
Revision ID: 861b52a2004e
Revises: b744e8a452fd
Create Date: 2024-06-05 13:35:19.012337
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import sqlite
# revision identifiers, used by Alembic.
revision = '861b52a2004e'
down_revision = 'b744e8a452fd'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('_alembic_tmp__basicsubmission')
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.create_unique_constraint(None, ['id'])
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.add_column(sa.Column('artic_date', sa.TIMESTAMP(), nullable=True))
batch_op.add_column(sa.Column('ngs_date', sa.TIMESTAMP(), nullable=True))
batch_op.add_column(sa.Column('gel_date', sa.TIMESTAMP(), nullable=True))
batch_op.add_column(sa.Column('gel_barcode', sa.String(length=16), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.drop_column('gel_barcode')
batch_op.drop_column('gel_date')
batch_op.drop_column('ngs_date')
batch_op.drop_column('artic_date')
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
op.create_table('_alembic_tmp__basicsubmission',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('rsl_plate_num', sa.VARCHAR(length=32), nullable=False),
sa.Column('submitter_plate_num', sa.VARCHAR(length=127), nullable=True),
sa.Column('submitted_date', sa.TIMESTAMP(), nullable=True),
sa.Column('submitting_lab_id', sa.INTEGER(), nullable=True),
sa.Column('sample_count', sa.INTEGER(), nullable=True),
sa.Column('extraction_kit_id', sa.INTEGER(), nullable=True),
sa.Column('submission_type_name', sa.VARCHAR(), nullable=True),
sa.Column('technician', sa.VARCHAR(length=64), nullable=True),
sa.Column('reagents_id', sa.VARCHAR(), nullable=True),
sa.Column('extraction_info', sqlite.JSON(), nullable=True),
sa.Column('run_cost', sa.FLOAT(), nullable=True),
sa.Column('signed_by', sa.VARCHAR(length=32), nullable=True),
sa.Column('comment', sqlite.JSON(), nullable=True),
sa.Column('submission_category', sa.VARCHAR(length=64), nullable=True),
sa.Column('cost_centre', sa.VARCHAR(length=64), nullable=True),
sa.Column('contact_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['contact_id'], ['_contact.id'], ondelete='SET NULL'),
sa.ForeignKeyConstraint(['extraction_kit_id'], ['_kittype.id'], ondelete='SET NULL'),
sa.ForeignKeyConstraint(['reagents_id'], ['_reagent.id'], ondelete='SET NULL'),
sa.ForeignKeyConstraint(['submission_type_name'], ['_submissiontype.name'], ondelete='SET NULL'),
sa.ForeignKeyConstraint(['submitting_lab_id'], ['_organization.id'], ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('rsl_plate_num'),
sa.UniqueConstraint('submitter_plate_num')
)
# ### end Alembic commands ###

View File

@@ -1,34 +0,0 @@
"""Adding ranking to SubmissionSampleAssociation
Revision ID: 874af342c82c
Revises: a04c25fd9138
Create Date: 2024-05-03 15:08:20.194275
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '874af342c82c'
down_revision = 'a04c25fd9138'
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('submission_rank', sa.INTEGER(), nullable=False, default=1))
# batch_op.create_unique_constraint(None, ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
batch_op.drop_column('submission_rank')
# ### end Alembic commands ###

View File

@@ -1,50 +0,0 @@
"""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 ###

View File

@@ -1,38 +0,0 @@
"""splitting off sample info in SubmissionType
Revision ID: a04c25fd9138
Revises: 6d2a357860ef
Create Date: 2024-05-01 09:11:44.957532
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a04c25fd9138'
down_revision = '6d2a357860ef'
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.create_unique_constraint(None, ['id'])
with op.batch_alter_table('_submissiontype', schema=None) as batch_op:
batch_op.add_column(sa.Column('sample_map', sa.JSON(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_submissiontype', schema=None) as batch_op:
batch_op.drop_column('sample_map')
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
# ### end Alembic commands ###

View File

@@ -1,40 +0,0 @@
"""Attaching contact to submission
Revision ID: b744e8a452fd
Revises: f829a8ab292f
Create Date: 2024-06-04 14:21:38.163431
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b744e8a452fd'
down_revision = 'f829a8ab292f'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_basicsubmission', schema=None) as batch_op:
batch_op.add_column(sa.Column('contact_id', sa.INTEGER(), nullable=True))
batch_op.create_foreign_key('fk_BS_contact_id', '_contact', ['contact_id'], ['id'], ondelete='SET NULL')
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.create_unique_constraint(None, ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
with op.batch_alter_table('_basicsubmission', schema=None) as batch_op:
batch_op.drop_constraint('fk_BS_contact_id', type_='foreignkey')
batch_op.drop_column('contact_id')
# ### end Alembic commands ###

View File

@@ -1,42 +0,0 @@
"""adding gel image, info
Revision ID: c4201b0ea9fe
Revises: 70d5a751f579
Create Date: 2024-01-30 08:42:03.928933
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c4201b0ea9fe'
down_revision = '70d5a751f579'
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.create_unique_constraint("unique_ssa_id", ['id'])
with op.batch_alter_table('_wastewaterassociation', schema=None) as batch_op:
batch_op.alter_column('id',
existing_type=sa.INTEGER(),
nullable=False)
# ### 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.alter_column('id',
existing_type=sa.INTEGER(),
nullable=True)
with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
batch_op.drop_constraint("unique_ssa_id", type_='unique')
# ### end Alembic commands ###

View File

@@ -1,95 +0,0 @@
"""Adding tips
Revision ID: d2b094cfa308
Revises: 861b52a2004e
Create Date: 2024-06-11 13:16:57.319769
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd2b094cfa308'
down_revision = '861b52a2004e'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('_tiprole',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_process_tiprole',
sa.Column('process_id', sa.INTEGER(), nullable=True),
sa.Column('tiprole_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['process_id'], ['_process.id'], ),
sa.ForeignKeyConstraint(['tiprole_id'], ['_tiprole.id'], )
)
op.create_table('_submissiontypetiproleassociation',
sa.Column('tiprole_id', sa.INTEGER(), nullable=False),
sa.Column('submissiontype_id', sa.INTEGER(), nullable=False),
sa.Column('uses', sa.JSON(), nullable=True),
sa.Column('static', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['submissiontype_id'], ['_submissiontype.id'], ),
sa.ForeignKeyConstraint(['tiprole_id'], ['_tiprole.id'], ),
sa.PrimaryKeyConstraint('tiprole_id', 'submissiontype_id')
)
op.create_table('_tips',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('role_id', sa.INTEGER(), nullable=True),
sa.Column('name', sa.String(length=64), nullable=True),
sa.Column('lot', sa.String(length=64), nullable=True),
sa.ForeignKeyConstraint(['role_id'], ['_tiprole.id'], name='fk_tip_role_id', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('_equipment_tips',
sa.Column('equipment_id', sa.INTEGER(), nullable=True),
sa.Column('tips_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['equipment_id'], ['_equipment.id'], ),
sa.ForeignKeyConstraint(['tips_id'], ['_tips.id'], )
)
op.create_table('_submissiontipsassociation',
sa.Column('tip_id', sa.INTEGER(), nullable=False),
sa.Column('submission_id', sa.INTEGER(), nullable=False),
sa.Column('role_name', sa.String(), nullable=False),
# sa.ForeignKeyConstraint(['role_name'], ['_tiprole.name'], ),
sa.ForeignKeyConstraint(['submission_id'], ['_basicsubmission.id'], ),
sa.ForeignKeyConstraint(['tip_id'], ['_tips.id'], ),
sa.PrimaryKeyConstraint('tip_id', 'submission_id', 'role_name')
)
op.create_table('_tiproles_tips',
sa.Column('tiprole_id', sa.INTEGER(), nullable=True),
sa.Column('tips_id', sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(['tiprole_id'], ['_tiprole.id'], ),
sa.ForeignKeyConstraint(['tips_id'], ['_tips.id'], )
)
# op.create_table('_submissions_tips',
# sa.Column('submission_id', sa.INTEGER(), nullable=True),
# sa.Column('tips_id', sa.INTEGER(), nullable=True),
# sa.ForeignKeyConstraint(['submission_id'], ['_basicsubmission.id'], ),
# sa.ForeignKeyConstraint(['tips_id'], ['_tips.id'], )
# )
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.create_unique_constraint("unique_ssa_id", ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
op.drop_table('_submissions_tips')
op.drop_table('_tiproles_tips')
op.drop_table('_submissiontipassociation')
op.drop_table('_equipment_tips')
op.drop_table('_tips')
op.drop_table('_submissiontypetiproleassociation')
op.drop_table('_process_tiprole')
op.drop_table('_tiprole')
# ### end Alembic commands ###

View File

@@ -1,33 +0,0 @@
"""adding default info to submissiontype
Revision ID: e6647bd661d9
Revises: f18487b41f45
Create Date: 2024-04-22 12:02:21.512781
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e6647bd661d9'
down_revision = 'f18487b41f45'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_submissiontype', schema=None) as batch_op:
batch_op.add_column(sa.Column('defaults', sa.JSON(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_submissiontype', schema=None) as batch_op:
batch_op.drop_column('defaults')
# ### end Alembic commands ###

View File

@@ -1,51 +0,0 @@
"""adding source plates to Artic submission...again
Revision ID: f18487b41f45
Revises: fabf697c721d
Create Date: 2024-04-17 10:42:30.508213
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f18487b41f45'
down_revision = 'fabf697c721d'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# op.drop_table('_alembic_tmp__submissionsampleassociation')
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.create_unique_constraint("ssa_id", ['id'])
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.add_column(sa.Column('source_plates', sa.JSON(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.drop_column('source_plates')
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
# op.create_table('_alembic_tmp__submissionsampleassociation',
# sa.Column('sample_id', sa.INTEGER(), nullable=False),
# sa.Column('submission_id', sa.INTEGER(), nullable=False),
# sa.Column('row', sa.INTEGER(), nullable=False),
# sa.Column('column', sa.INTEGER(), nullable=False),
# sa.Column('base_sub_type', sa.VARCHAR(), nullable=True),
# sa.Column('id', sa.INTEGER(), server_default=sa.text('1'), nullable=False),
# sa.ForeignKeyConstraint(['sample_id'], ['_basicsample.id'], ),
# sa.ForeignKeyConstraint(['submission_id'], ['_basicsubmission.id'], ),
# sa.PrimaryKeyConstraint('submission_id', 'row', 'column'),
# sa.UniqueConstraint('id', name='ssa_unique')
# )
# ### end Alembic commands ###

View File

@@ -1,39 +0,0 @@
"""Adding configitems to db
Revision ID: f829a8ab292f
Revises: 874af342c82c
Create Date: 2024-05-15 14:03:11.767480
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f829a8ab292f'
down_revision = '874af342c82c'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('_configitem',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('key', sa.String(), nullable=True),
sa.Column('value', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.create_unique_constraint(None, ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint(None, type_='unique')
op.drop_table('_configitem')
# ### end Alembic commands ###

View File

@@ -1,48 +0,0 @@
"""adding source plates to Artic submission
Revision ID: fabf697c721d
Revises: 70426df72f80
Create Date: 2024-03-06 11:01:34.794411
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fabf697c721d'
down_revision = '70426df72f80'
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.create_unique_constraint("ssa_unique", ['id'])
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.add_column(sa.Column('source_plates', sa.JSON(), nullable=True))
with op.batch_alter_table('_wastewaterassociation', schema=None) as batch_op:
batch_op.alter_column('id',
existing_type=sa.INTEGER(),
nullable=False)
# ### 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.alter_column('id',
existing_type=sa.INTEGER(),
nullable=True)
with op.batch_alter_table('_wastewaterartic', schema=None) as batch_op:
batch_op.drop_column('source_plates')
# with op.batch_alter_table('_submissionsampleassociation', schema=None) as batch_op:
# batch_op.drop_constraint("ssa_unique", type_='unique')
# ### end Alembic commands ###