From 5417d3adea3e25ac13525a5d7896c14f59db7668 Mon Sep 17 00:00:00 2001 From: sebastiencarceles Date: Tue, 7 Feb 2023 11:59:43 +0100 Subject: [PATCH 1/2] add external id index to champs --- .../20230207105539_add_external_id_index_to_champs.rb | 7 +++++++ db/schema.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230207105539_add_external_id_index_to_champs.rb diff --git a/db/migrate/20230207105539_add_external_id_index_to_champs.rb b/db/migrate/20230207105539_add_external_id_index_to_champs.rb new file mode 100644 index 000000000..14d47c143 --- /dev/null +++ b/db/migrate/20230207105539_add_external_id_index_to_champs.rb @@ -0,0 +1,7 @@ +class AddExternalIdIndexToChamps < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + def change + add_index :champs, :external_id, algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index d465805de..59abcc837 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.define(version: 2023_02_03_134127) do +ActiveRecord::Schema.define(version: 2023_02_07_105539) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -233,6 +233,7 @@ ActiveRecord::Schema.define(version: 2023_02_03_134127) do t.jsonb "value_json" t.index ["dossier_id"], name: "index_champs_on_dossier_id" t.index ["etablissement_id"], name: "index_champs_on_etablissement_id" + t.index ["external_id"], name: "index_champs_on_external_id" t.index ["parent_id"], name: "index_champs_on_parent_id" t.index ["private"], name: "index_champs_on_private" t.index ["row_id"], name: "index_champs_on_row_id" From 8220ea58ef409b52900eba062fd92f7383ce1b78 Mon Sep 17 00:00:00 2001 From: sebastiencarceles Date: Tue, 7 Feb 2023 14:34:52 +0100 Subject: [PATCH 2/2] review: make use of migration helper --- .../20230207105539_add_external_id_index_to_champs.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/migrate/20230207105539_add_external_id_index_to_champs.rb b/db/migrate/20230207105539_add_external_id_index_to_champs.rb index 14d47c143..058bf31d9 100644 --- a/db/migrate/20230207105539_add_external_id_index_to_champs.rb +++ b/db/migrate/20230207105539_add_external_id_index_to_champs.rb @@ -1,7 +1,13 @@ class AddExternalIdIndexToChamps < ActiveRecord::Migration[6.1] + include Database::MigrationHelpers + disable_ddl_transaction! - def change - add_index :champs, :external_id, algorithm: :concurrently + def up + add_concurrent_index :champs, :external_id + end + + def down + remove_index :champs, column: :external_id end end