]> git.openstreetmap.org Git - rails.git/commitdiff
Adds index to notes on description column
authorNenad Vujicic <nenadus@gmail.com>
Thu, 6 Feb 2025 21:01:21 +0000 (22:01 +0100)
committerNenad Vujicic <nenadus@gmail.com>
Wed, 12 Feb 2025 17:22:50 +0000 (18:22 +0100)
Adds text index to description column to table notes.

app/models/note.rb
db/migrate/20250206202905_add_text_index_to_notes.rb [new file with mode: 0644]
db/structure.sql

index 807ee9ec8b99a7e021ac9ba8b46963c2f74cd2a8..b7215d6f7706084318ecefcd845d303771f14fc9 100644 (file)
 #
 # Indexes
 #
-#  notes_created_at_idx   (created_at)
-#  notes_tile_status_idx  (tile,status)
-#  notes_updated_at_idx   (updated_at)
+#  index_notes_on_description  (to_tsvector('english'::regconfig, description)) USING gin
+#  notes_created_at_idx        (created_at)
+#  notes_tile_status_idx       (tile,status)
+#  notes_updated_at_idx        (updated_at)
 #
 # Foreign Keys
 #
diff --git a/db/migrate/20250206202905_add_text_index_to_notes.rb b/db/migrate/20250206202905_add_text_index_to_notes.rb
new file mode 100644 (file)
index 0000000..7798f22
--- /dev/null
@@ -0,0 +1,7 @@
+class AddTextIndexToNotes < ActiveRecord::Migration[7.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :notes, "to_tsvector('english', description)", :using => "GIN", :name => "index_notes_on_description", :algorithm => :concurrently
+  end
+end
index 9093c47fe72c5c075e58bb5ff6659f54ec8e974b..d23c2d7487802486884652bc258e904134844831 100644 (file)
@@ -2540,6 +2540,13 @@ CREATE INDEX index_note_comments_on_created_at ON public.note_comments USING btr
 CREATE INDEX index_note_subscriptions_on_note_id ON public.note_subscriptions USING btree (note_id);
 
 
+--
+-- Name: index_notes_on_description; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_notes_on_description ON public.notes USING gin (to_tsvector('english'::regconfig, description));
+
+
 --
 -- Name: index_oauth_access_grants_on_application_id; Type: INDEX; Schema: public; Owner: -
 --
@@ -3422,6 +3429,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('23'),
 ('22'),
 ('21'),
+('20250206202905'),
 ('20250121191749'),
 ('20250105154621'),
 ('20250104140952'),