From 3aa3b75da9d775052ce30f92223568b9948fb739 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 30 Jun 2026 10:04:35 +0200 Subject: [PATCH] Fix missing unique index on keypairs URI (#39668) --- ...260629124055_add_new_index_on_uri_to_keypairs.rb | 9 --------- ...29124613_remove_old_index_on_uri_from_keypair.rb | 9 --------- ...70531_revert_add_new_index_on_uri_to_keypairs.rb | 13 +++++++++++++ ...0_revert_remove_old_index_on_uri_from_keypair.rb | 13 +++++++++++++ db/schema.rb | 4 ++-- 5 files changed, 28 insertions(+), 20 deletions(-) delete mode 100644 db/migrate/20260629124055_add_new_index_on_uri_to_keypairs.rb delete mode 100644 db/migrate/20260629124613_remove_old_index_on_uri_from_keypair.rb create mode 100644 db/migrate/20260630070531_revert_add_new_index_on_uri_to_keypairs.rb create mode 100644 db/migrate/20260630070600_revert_remove_old_index_on_uri_from_keypair.rb diff --git a/db/migrate/20260629124055_add_new_index_on_uri_to_keypairs.rb b/db/migrate/20260629124055_add_new_index_on_uri_to_keypairs.rb deleted file mode 100644 index ba40bc0979..0000000000 --- a/db/migrate/20260629124055_add_new_index_on_uri_to_keypairs.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddNewIndexOnUriToKeypairs < ActiveRecord::Migration[8.1] - disable_ddl_transaction! - - def change - add_index :keypairs, :uri, name: :index_keypairs_on_non_null_uri, unique: true, where: 'uri IS NOT NULL', algorithm: :concurrently - end -end diff --git a/db/migrate/20260629124613_remove_old_index_on_uri_from_keypair.rb b/db/migrate/20260629124613_remove_old_index_on_uri_from_keypair.rb deleted file mode 100644 index 42b507b4a9..0000000000 --- a/db/migrate/20260629124613_remove_old_index_on_uri_from_keypair.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class RemoveOldIndexOnUriFromKeypair < ActiveRecord::Migration[8.1] - disable_ddl_transaction! - - def change - remove_index :keypairs, :uri, name: :index_keypairs_on_uri, unique: true, algorithm: :concurrently - end -end diff --git a/db/migrate/20260630070531_revert_add_new_index_on_uri_to_keypairs.rb b/db/migrate/20260630070531_revert_add_new_index_on_uri_to_keypairs.rb new file mode 100644 index 0000000000..5be306bb35 --- /dev/null +++ b/db/migrate/20260630070531_revert_add_new_index_on_uri_to_keypairs.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RevertAddNewIndexOnUriToKeypairs < ActiveRecord::Migration[8.1] + disable_ddl_transaction! + + def up + return unless index_exists?(:keypairs, :uri, name: :index_keypairs_on_non_null_uri) + + remove_index :keypairs, :uri, name: :index_keypairs_on_non_null_uri + end + + def down; end +end diff --git a/db/migrate/20260630070600_revert_remove_old_index_on_uri_from_keypair.rb b/db/migrate/20260630070600_revert_remove_old_index_on_uri_from_keypair.rb new file mode 100644 index 0000000000..c8b289944f --- /dev/null +++ b/db/migrate/20260630070600_revert_remove_old_index_on_uri_from_keypair.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RevertRemoveOldIndexOnUriFromKeypair < ActiveRecord::Migration[8.1] + disable_ddl_transaction! + + def up + return if index_exists?(:keypairs, :uri, name: :index_keypairs_on_uri) + + add_index :keypairs, :uri, name: :index_keypairs_on_uri, unique: true, algorithm: :concurrently + end + + def down; end +end diff --git a/db/schema.rb b/db/schema.rb index ef3d1138ca..99e9a75cb9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_06_29_125939) do +ActiveRecord::Schema[8.1].define(version: 2026_06_30_070600) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -714,7 +714,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_06_29_125939) do t.string "uri" t.index ["account_id", "local_fragment"], name: "index_keypairs_on_account_id_and_local_fragment", unique: true, where: "(local_fragment IS NOT NULL)" t.index ["account_id"], name: "index_keypairs_on_account_id" - t.index ["uri"], name: "index_keypairs_on_non_null_uri", unique: true, where: "(uri IS NOT NULL)" + t.index ["uri"], name: "index_keypairs_on_uri", unique: true end create_table "list_accounts", force: :cascade do |t|