diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-04-21 12:10:45 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-04-21 13:27:34 +0300 |
commit | ee6f941ae1840bfcec4f6ef6cf3575d4c9c57852 (patch) | |
tree | 517a2f42600e3f46f62bae3c989ec6c5f19194f2 /db | |
parent | ad016cbd8689afc92c83f7347daffbcd7ea2dcb1 (diff) |
Merge branch 'add-pg-trgrm-in-migration' into 'master'
Attempt to create pg_trgm extension in migration for test/dev environments
See merge request !3805
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], |