Packed into a gem from here: http://timnew.github.com/blog/2012/07/17/use-postgres-multiple-schema-database-in-rails/
Thanks. @TimNew!
Add this line to your application's Gemfile:
gem 'multi_schema'
And then execute:
$ bundle
Or install it yourself as:
$ gem install multi_schema
You can use it as the utility class in the old-fashioned way:
MultiSchema.with_in_schemas :except => :public do
# Play around the data in one schema
end
Or you can use it in a DSL-like way:
class SomeMigration < ActiveRecord::Migration
include MultiSchema
def change
with_in_schemas :except => :public do
# Play around the data in one schema
end
end
end
- with_in_schemas yield all user schemas in the database
- with_in_schemas :only => %w(schema1 schema2) populates all given schemas.
- with_in_schemas :except => %w(schema1 schema2) populates all except given schemas.
- with_in_schemas :except => [:public] is equivalent to with_in_schemas :except => ['public']
- with_in_schemas :only => [:public] is equivalent to with_in_schemas :only => :public and equivalent to with_in_schemas :public
- with_in_schemas :except => [:public] is equivalent to with_in_schemas :except => :public
tests, ci...
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request