Skip to content

Instantly share code, notes, and snippets.

@kucaahbe
Created August 6, 2014 14:23
Show Gist options
  • Save kucaahbe/e807eb568e308886cb59 to your computer and use it in GitHub Desktop.
Save kucaahbe/e807eb568e308886cb59 to your computer and use it in GitHub Desktop.
enable hstore in postgres (requires user to be superuser)
class EnableHstore < ActiveRecord::Migration
def up
enable_extension :hstore
rescue ActiveRecord::StatementInvalid => maybe_hstore_exception
if maybe_hstore_exception.original_exception.is_a? PG::UndefinedFile
STDERR.puts <<MSG
*****************************************************
Exception occured during enabling "hstore" extension.
If you your OS is debian/ubuntu then try to install "postgresql-contrib" package.
*****************************************************
MSG
end
raise maybe_hstore_exception
end
def down
disable_extension :hstore
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment