ensure extensions will work for specs with multiple shards
Change-Id: I4ff6ab571f7995469a89f605386e9f6c49718d19 Reviewed-on: https://gerrit.instructure.com/29677 Reviewed-by: Jon Willesen <jonw@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
0ca6f1f9aa
commit
6b47a6c1e6
|
@ -231,6 +231,17 @@ module Helpers
|
|||
end
|
||||
end
|
||||
|
||||
# Make sure extensions will work with dynamically created shards
|
||||
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' &&
|
||||
ActiveRecord::Base.connection.schema_search_path == 'public'
|
||||
%w{pg_trgm pg_collkey}.each do |extension|
|
||||
current_schema = ActiveRecord::Base.connection.select_value("SELECT nspname FROM pg_extension INNER JOIN pg_namespace ON extnamespace=pg_namespace.oid WHERE extname='#{extension}'")
|
||||
if current_schema && current_schema == 'public'
|
||||
ActiveRecord::Base.connection.execute("ALTER EXTENSION #{extension} SET SCHEMA pg_catalog") rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
(CANVAS_RAILS2 ? Spec::Runner : RSpec).configure do |config|
|
||||
# If you're not using ActiveRecord you should remove these
|
||||
# lines, delete config/database.yml and disable :active_record
|
||||
|
|
Loading…
Reference in New Issue