Adding the migration - very destructive, but required for running the app.

minor fixes - there is still some weird problems with study id and user id being null that I need to track down, but the issue is sporadic, and hard to track down.
This commit is contained in:
Dan 2022-02-10 11:50:31 -05:00
parent 3ebffeed33
commit eb7760fa55
3 changed files with 68 additions and 3 deletions

View File

@ -29,9 +29,9 @@ class ApiError(Exception):
self.offset = offset
self.error_type = error_type
self.error_line = error_line
if hasattr(g, 'user'):
try:
user = g.user.uid
else:
except Exception as e:
user = 'Unknown'
self.task_user = user
# This is for sentry logging into Slack

View File

@ -468,7 +468,7 @@ class StudyService(object):
@staticmethod
def add_all_workflow_specs_to_study(study_model: StudyModel, specs: List[WorkflowSpecInfo]):
existing_models = session.query(WorkflowModel).filter(WorkflowModel.study == study_model).all()
existing_spec_ids = map(lambda x: x.workflow_spec_id, existing_models)
existing_spec_ids = list(map(lambda x: x.workflow_spec_id, existing_models))
errors = []
for workflow_spec in specs:
if workflow_spec.id in existing_spec_ids:

View File

@ -0,0 +1,65 @@
"""empty message
Revision ID: 29bad12c9945
Revises: c51ea6590f5d
Create Date: 2022-02-10 10:24:27.796228
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '29bad12c9945'
down_revision = 'c51ea6590f5d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('task_event_workflow_spec_id_fkey', 'task_event', type_='foreignkey')
op.drop_constraint('workflow_workflow_spec_id_fkey', 'workflow', type_='foreignkey')
op.drop_constraint('workflow_library_workflow_spec_id_fkey', 'workflow_library', type_='foreignkey')
op.drop_table('workflow_library')
op.drop_table('workflow_spec')
op.drop_table('workflow_spec_category')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key('workflow_workflow_spec_id_fkey', 'workflow', 'workflow_spec', ['workflow_spec_id'], ['id'])
op.create_foreign_key('task_event_workflow_spec_id_fkey', 'task_event', 'workflow_spec', ['workflow_spec_id'], ['id'])
op.create_table('workflow_spec',
sa.Column('id', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('display_name', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('is_master_spec', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('category_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('display_order', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('standalone', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('library', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('primary_file_name', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('primary_process_id', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('is_review', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['category_id'], ['workflow_spec_category.id'], name='workflow_spec_category_id_fkey'),
sa.PrimaryKeyConstraint('id', name='workflow_spec_pkey'),
postgresql_ignore_search_path=False
)
op.create_table('workflow_library',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('workflow_spec_id', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('library_spec_id', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['library_spec_id'], ['workflow_spec.id'], name='workflow_library_library_spec_id_fkey'),
sa.ForeignKeyConstraint(['workflow_spec_id'], ['workflow_spec.id'], name='workflow_library_workflow_spec_id_fkey'),
sa.PrimaryKeyConstraint('id', name='workflow_library_pkey')
)
op.create_table('workflow_spec_category',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('display_name', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('display_order', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('admin', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name='workflow_spec_category_pkey')
)
# ### end Alembic commands ###