diff --git a/db/migrate/20180514142421_rename_switchman_shards_fk_if_necessary.rb b/db/migrate/20180514142421_rename_switchman_shards_fk_if_necessary.rb new file mode 100644 index 00000000000..712e277190e --- /dev/null +++ b/db/migrate/20180514142421_rename_switchman_shards_fk_if_necessary.rb @@ -0,0 +1,13 @@ +class RenameSwitchmanShardsFkIfNecessary < ActiveRecord::Migration[5.1] + tag :predeploy + + def up + if connection.send(:postgresql_version) >= 90400 + alter_constraint(:switchman_shards, find_foreign_key(:switchman_shards, :switchman_shards, column: :delayed_jobs_shard_id), new_name: 'fk_rails_45bd80a9c8') + else + remove_foreign_key_if_exists :switchman_shards, :switchman_shards, column: :delayed_jobs_shard_id + add_foreign_key :switchman_shards, :switchman_shards, column: :delayed_jobs_shard_id + end + + end +end