mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 04:36:11 +10:00
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
This commit is contained in:
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user