diff options
author | Stan Hu <stanhu@gmail.com> | 2016-04-18 16:00:30 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-04-20 20:59:01 -0700 |
commit | dcd54f63451ab689ec03653b525b5f218a9f420a (patch) | |
tree | 37eba7977e18cb67cae1ae335d7d4ec3ac27dca9 /db | |
parent | bfa16dbcfba2a3233209f6403a0074d42e664df6 (diff) | |
download | gitlab-ce-dcd54f63451ab689ec03653b525b5f218a9f420a.tar.gz |
Attempt to create pg_trgm extension in migration for test/dev environments
Closes #15210
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20160226114608_add_trigram_indexes_for_searching.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb b/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb index 003169c13c6..d7b00e3d6ed 100644 --- a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb +++ b/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb @@ -4,6 +4,8 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration def up return unless Gitlab::Database.postgresql? + create_trigrams_extension + unless trigrams_enabled? raise 'You must enable the pg_trgm extension. You can do so by running ' \ '"CREATE EXTENSION pg_trgm;" as a PostgreSQL super user, this must be ' \ @@ -37,6 +39,15 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration row && row['enabled'] == 't' ? true : false end + def create_trigrams_extension + # This may not work if the user doesn't have permission. We attempt in + # case we do have permission, particularly for test/dev environments. + begin + enable_extension 'pg_trgm' + rescue + end + end + def to_index { ci_runners: [:token, :description], |