Commit dcd54f63 authored by Stan Hu's avatar Stan Hu

Attempt to create pg_trgm extension in migration for test/dev environments

Closes #15210
parent bfa16dbc
...@@ -4,6 +4,8 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration ...@@ -4,6 +4,8 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration
def up def up
return unless Gitlab::Database.postgresql? return unless Gitlab::Database.postgresql?
create_trigrams_extension
unless trigrams_enabled? unless trigrams_enabled?
raise 'You must enable the pg_trgm extension. You can do so by running ' \ 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 ' \ '"CREATE EXTENSION pg_trgm;" as a PostgreSQL super user, this must be ' \
...@@ -37,6 +39,15 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration ...@@ -37,6 +39,15 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration
row && row['enabled'] == 't' ? true : false row && row['enabled'] == 't' ? true : false
end 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 def to_index
{ {
ci_runners: [:token, :description], ci_runners: [:token, :description],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment