From 4667b20c007c4bce248ac6cc458414fefa058bb8 Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Wed, 6 Feb 2019 20:35:22 +0100 Subject: [PATCH] add trigram database index on tags --- db/migrate/20190206193120_add_index_to_tags.rb | 18 ++++++++++++++++++ db/schema.rb | 1 + 2 files changed, 19 insertions(+) create mode 100644 db/migrate/20190206193120_add_index_to_tags.rb diff --git a/db/migrate/20190206193120_add_index_to_tags.rb b/db/migrate/20190206193120_add_index_to_tags.rb new file mode 100644 index 00000000000..5257ebba003 --- /dev/null +++ b/db/migrate/20190206193120_add_index_to_tags.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexToTags < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_tags_on_name_trigram' + + disable_ddl_transaction! + + def up + add_concurrent_index :tags, :name, name: INDEX_NAME, using: :gin, opclasses: { name: :gin_trgm_ops } + end + + def down + remove_concurrent_index_by_name(:tags, INDEX_NAME) + end +end diff --git a/db/schema.rb b/db/schema.rb index a7a83475679..d4166e32112 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2053,6 +2053,7 @@ ActiveRecord::Schema.define(version: 20190220150130) do t.string "name" t.integer "taggings_count", default: 0 t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree + t.index ["name"], name: "index_tags_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} end create_table "term_agreements", force: :cascade do |t| -- GitLab