Skip to content

Instantly share code, notes, and snippets.

@kubakrzempek
Last active August 29, 2015 14:18
Show Gist options
  • Save kubakrzempek/1754d2220f9addbdb49e to your computer and use it in GitHub Desktop.
Save kubakrzempek/1754d2220f9addbdb49e to your computer and use it in GitHub Desktop.
Rails and postgresql extensions
# It doesn't work...
class InstallTrigramContribPackage < ActiveRecord::Migration
def up
execute 'CREATE EXTENSION pg_trgm'
end
def down
execute 'DROP EXTENSION pg_trgm'
end
end
# ... this one does...
class InstallTrigramContribPackage < ActiveRecord::Migration
def up
execute 'CREATE EXTENSION IF NOT EXISTS pg_trgm'
end
def down
execute 'DROP EXTENSION pg_trgm'
end
end
# ... but this looks better
class InstallTrigramContribPackage < ActiveRecord::Migration
def up
enable_extension "pg_trgm"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment