Skip to content

razum2um/multi_schema

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

MultiSchema

Packed into a gem from here: http://timnew.github.com/blog/2012/07/17/use-postgres-multiple-schema-database-in-rails/

Thanks. @TimNew!

Installation

Add this line to your application's Gemfile:

gem 'multi_schema'

And then execute:

$ bundle

Or install it yourself as:

$ gem install multi_schema

Usage

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

TODO

tests, ci...

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

allows you to switch over the postgres schemas in runtime inside ruby/rails

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages