#200 alembic: fix upgrade on production
Closed 2 years ago by kparal. Opened 2 years ago by kparal.

@@ -67,7 +67,12 @@ 

      op.create_unique_constraint(op.f('uq_milestone_blocker_tracker'), 'milestone', ['blocker_tracker'])

      op.create_unique_constraint(op.f('uq_milestone_fe_tracker'), 'milestone', ['fe_tracker'])

      op.create_unique_constraint(op.f('uq_milestone_name'), 'milestone', ['name'])

-     op.drop_constraint('user_info_api_key_hash_key', 'user_info', type_='unique')

+ 

+     # production DB doesn't have this constraint (because of imperfect upgrades), it needs to be

+     # rewritten into IF EXISTS form

+     # op.drop_constraint('user_info_api_key_hash_key', 'user_info', type_='unique')

+     op.execute("ALTER TABLE user_info DROP CONSTRAINT IF EXISTS user_info_api_key_hash_key")

+ 

      op.drop_constraint('user_info_bz_user_key', 'user_info', type_='unique')

      op.drop_constraint('user_info_fas_login_key', 'user_info', type_='unique')

      op.create_unique_constraint(op.f('uq_user_info_api_key_hash'), 'user_info', ['api_key_hash'])

Production DB doesn't have a particular constraint (because of imperfect
upgrades), we must drop it only if it exists.

Build succeeded.

Pull-Request has been closed by kparal

2 years ago
Metadata