From 4ea9414f2605543a267986e12a3ec4e59125bea5 Mon Sep 17 00:00:00 2001 From: Odumosu 'Dipo Date: Thu, 4 Jun 2020 14:16:34 +0100 Subject: [PATCH] fix: update migration script - this commit fixes an issue with the migration script where the user receives an `AttributeError` while running it - it also doesn't assume that QA is present on the form --- migrations/versions/1e17be41a449_migrate_qa_expressions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migrations/versions/1e17be41a449_migrate_qa_expressions.py b/migrations/versions/1e17be41a449_migrate_qa_expressions.py index 158db7ee0..bc066e975 100644 --- a/migrations/versions/1e17be41a449_migrate_qa_expressions.py +++ b/migrations/versions/1e17be41a449_migrate_qa_expressions.py @@ -22,7 +22,10 @@ def upgrade(): fetch_query = sa.sql.text( "SELECT id, quality_checks FROM form WHERE quality_checks IS NOT NULL OR quality_checks != 'null'::jsonb;") # noqa form_table = Form.__table__ - for form_id, quality_checks in op.execute(fetch_query).fetchall(): + connection = op.get_bind() + for form_id, quality_checks in connection.execute(fetch_query).fetchall(): + if not quality_checks: + continue for quality_check in quality_checks: if 'expression' not in quality_check: quality_check['expression'] = qb.build_expression(