From 63ed1b5bd79af6e7005025f3b7cc3651dafbb5bc Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Tue, 22 Oct 2024 10:47:24 +0800 Subject: [PATCH] DEV: Remove NULLS NOT DISTINCT from problem check trackers (#29327) We added NULLS NOT DISTINCT to a unique index on problem_check_trackers. This option is only available in PG15+. It does not in itself break PG13, but restoring a PG15+ backup to PG13 currently errors out. It seems this is an operation that's more common than we first thought. This commit fixes that by removing the NULLS NOT DISTINCT. We already have another, backwards-compatible approach to do the same thing in place, so this shouldn't change existing behaviour. --- ...nulls_not_distinct_from_problem_check_trackers.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrate/20241022022326_remove_nulls_not_distinct_from_problem_check_trackers.rb diff --git a/db/migrate/20241022022326_remove_nulls_not_distinct_from_problem_check_trackers.rb b/db/migrate/20241022022326_remove_nulls_not_distinct_from_problem_check_trackers.rb new file mode 100644 index 00000000000..1e2317012a9 --- /dev/null +++ b/db/migrate/20241022022326_remove_nulls_not_distinct_from_problem_check_trackers.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +class RemoveNullsNotDistinctFromProblemCheckTrackers < ActiveRecord::Migration[7.1] + def up + remove_index :problem_check_trackers, %i[identifier target], if_exists: true + add_index :problem_check_trackers, %i[identifier target], unique: true + end + + def down + remove_index :problem_check_trackers, %i[identifier target], if_exists: true + add_index :problem_check_trackers, %i[identifier target], unique: true, nulls_not_distinct: true + end +end