Skip to content

Instantly share code, notes, and snippets.

@yoshuki
Created October 27, 2016 12:45
Show Gist options
  • Save yoshuki/3f42cb18498dc3509b36a6472f1b3272 to your computer and use it in GitHub Desktop.
Save yoshuki/3f42cb18498dc3509b36a6472f1b3272 to your computer and use it in GitHub Desktop.
class EnablePGroonga < ActiveRecord::Migration
def change
reversible do |r|
current_database = select_value('SELECT current_database()')
r.up do
enable_extension('pgroonga')
execute("ALTER DATABASE #{current_database} SET search_path = '$user',public,pgroonga,pg_catalog;")
end
r.down do
execute("ALTER DATABASE #{current_database} RESET search_path;")
disable_extension('pgroonga')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment