Skip to content

Commit

Permalink
Convert packagename back to string on downgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
marySalvi committed Dec 9, 2024
1 parent 31143e9 commit 19fcef5
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,28 @@ def upgrade():

def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
submission_metadata = table(
"submission_metadata",
column("id", sa.String),
column("metadata_submission", JSONB),
column("study_name", sa.String),
column("templates", JSONB),
)
connection = op.get_bind()
submissions = connection.execute(
sa.select([submission_metadata.c.id, submission_metadata.c.metadata_submission])
)
for submission in submissions:
metadata_submission = submission.metadata_submission
package_name = metadata_submission.get("packageName", None)
# The first element of this list would be the default env_package
if isinstance(package_name, list):
metadata_submission["packageName"] = package_name[0]

update_stmt = (
submission_metadata.update()
.where(submission_metadata.c.id == submission.id)
.values(metadata_submission=metadata_submission)
)
connection.execute(update_stmt)
# ### end Alembic commands ###

0 comments on commit 19fcef5

Please sign in to comment.