Skip to content

Instantly share code, notes, and snippets.

@almaron
Created June 20, 2017 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save almaron/31cd181e6fb1c03ddb15633a80a05543 to your computer and use it in GitHub Desktop.
Save almaron/31cd181e6fb1c03ddb15633a80a05543 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
namespace :db do
desc 'Also create shared_extensions Schema'
task extensions: :environment do
# Create Schema
ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
# Enable Hstore
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
# Enable UUID-OSSP
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
end
end
Rake::Task['db:create'].enhance do
Rake::Task['db:extensions'].invoke
end
Rake::Task['db:test:purge'].enhance do
Rake::Task['db:extensions'].invoke
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment