From 5597eb4cc4f8739016c66a5e18d3875fcca059f7 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 18 Apr 2016 12:49:13 -0700 Subject: [PATCH] Fix db upgrade script b4456560d4f3 (#370) * Recreating db upgrade error first * Wrapping alter table calls in try statements --- ...6560d4f3_change_table_unique_constraint.py | 20 +++++++++++++------ run_tests.sh | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/caravel/migrations/versions/b4456560d4f3_change_table_unique_constraint.py b/caravel/migrations/versions/b4456560d4f3_change_table_unique_constraint.py index 0b8164d0c..1c5c50a5f 100644 --- a/caravel/migrations/versions/b4456560d4f3_change_table_unique_constraint.py +++ b/caravel/migrations/versions/b4456560d4f3_change_table_unique_constraint.py @@ -14,12 +14,20 @@ from alembic import op def upgrade(): - op.drop_constraint( - u'tables_table_name_key', 'tables', type_='unique') - op.create_unique_constraint( - u'_customer_location_uc', 'tables', - ['database_id', 'schema', 'table_name']) + try: + # Trying since sqlite doesn't like constraints + op.drop_constraint( + u'tables_table_name_key', 'tables', type_='unique') + op.create_unique_constraint( + u'_customer_location_uc', 'tables', + ['database_id', 'schema', 'table_name']) + except Exception: + pass def downgrade(): - op.drop_constraint(u'_customer_location_uc', 'tables', type_='unique') + try: + # Trying since sqlite doesn't like constraints + op.drop_constraint(u'_customer_location_uc', 'tables', type_='unique') + except Exception: + pass diff --git a/run_tests.sh b/run_tests.sh index bc22a8d6d..9fbb244b9 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,5 +2,6 @@ rm /tmp/caravel_unittests.db rm -f .coverage export CARAVEL_CONFIG=tests.caravel_test_config +set -e caravel/bin/caravel db upgrade python setup.py nosetests