multidb 3.2.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 871069e0b89ed728780ae50f13950dc1e8e1c6db
4
- data.tar.gz: 56645bb4e9fd29f8f696e6e2534f963ce414dc62
3
+ metadata.gz: c2b318704dc25c750faff4197c282bfc34ce3b44
4
+ data.tar.gz: a6245b07384d189337568ef08fd5fe0467f92926
5
5
  SHA512:
6
- metadata.gz: 67773f48625923f72efa87033d8e988ef36679c58d7ad928c1b79abd13722c54b14590c390c6e1d0c4542cb420199d8a709776ebdfbe2f0ef564086157909b74
7
- data.tar.gz: 8ca58cc43cc994807fb72979866defbaf325f861f77b5ab2809c55a08c10b17673b1bead7a26e4482e0aaf85bff395cb5dd64093e9241e7800144670bda76dd2
6
+ metadata.gz: 2a5928902bb85f89d26b096a663a7269dd2de47412bb2c9e61c952fe4bfce5732c83ecd37d1eb938e5169d164e3828b8a5f36af3e8adffbd1ca212324596db3f
7
+ data.tar.gz: abe71fcb71c0d8e70b8ec41fbb0611b5921d3449c3e7f9e22a79dbd2e58ce58d7afe4c6b9b329cdd66a7faa221455ebe40fa195c4e959bda63fb78a883808517
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.0
1
+ ruby-2.1.1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  MultiDB is a multitenant extension for Rails (or just ActiveRecord) that allows you to isolate each tenant into its own individual database without requiring major changes to your application code.
4
4
 
5
- MultiDB is _not_ meant for systems that may have large numbers of tenants; you wouldn't want to have that many databases. It was designed for a system with 100-200 tenants, with the option to go to 1,000, and an absolute upper limit of 10,000. If you anticipate having more, MultiDB may not be an appropriate solution. (MySQL itself does not specify an upper limit on the number of databases, but it will be constrained by open file limits and, in some cases, directory entry limits.)
5
+ MultiDB is _not_ meant for systems that may have large numbers of tenants; you wouldn't want to have that many databases. It was designed for a system with 200-500 tenants, with the option to go to 10,000, and an absolute upper limit of 25,000. If you anticipate having more, MultiDB may not be an appropriate solution. (MySQL itself does not specify an upper limit on the number of databases, but it will be constrained by open file limits and, in some cases, directory entry limits.)
6
6
 
7
7
  To minimize API changes for you, MultiDB patches ActiveRecord, ActionController and their associated rake tasks as needed to enable database switching at appropriate times and add support for three sets of schemas and migrations. ActiveRecord::SessionStore::Session has also been patched.
8
8
 
@@ -11,7 +11,8 @@ Internally, MultiDB refers to tenants as organizations. In addition to the organ
11
11
  MultiDB, when used with Rails (ActionController), determines which database to connect to at the beginning of each request by checking for `request.host`, `params[:org_code]`, then `session[:org_code]`. In a test environment, it can will also check the environment variable `RAILS_ORG`. If no organization code is found in any of those places, the sessions database is used (which is one reason it is important that no actual data be stored there).
12
12
 
13
13
 
14
- ## Compatibility
14
+ ## Versioning & Compatibility
15
+ MultiDB follows semantic versioning, but because it is closely tied to Rails/ActiveRecord, it uses the same major/minor version numbers to make it easy to determine which version of MultiDB to use. Patch numbers may vary.
15
16
 
16
17
  ### Rails & ActiveRecord
17
18
  MultiDB 3.2 works with Rails 3.2. A new branch will be created to work with Rails 4.
@@ -24,15 +25,15 @@ Warning: MultiDB works only with mysql2 at present. If you are handy with Ruby,
24
25
  MultiDB is known to work with [Makara](https://github.com/taskrabbit/makara) in a production environment.
25
26
 
26
27
 
27
- ##Get Started With MultiDB
28
+ ## Get Started
28
29
 
29
- Install the gem:
30
+ Add it to your Gemfile:
30
31
 
31
- gem install multidb
32
+ gem 'multidb', '~> 3.2.0' # note: MultiDB 3.2 works with Rails 3.2
32
33
 
33
- Or add it to your Gemfile:
34
+ Or install by hand:
34
35
 
35
- gem 'multidb'
36
+ gem install multidb
36
37
 
37
38
  Then have your Organization class inherit from MultiDB::Organization. This gets you:
38
39
 
@@ -7,9 +7,10 @@ class ActionController::Base
7
7
 
8
8
  # request is first priority
9
9
  if params[:org_code]
10
- if session[:org_code] && session[:org_code] != params[:org_code]
11
- reset_session
12
- end
10
+ # AKN: we should let the gem user decide whether to do this
11
+ # if session[:org_code] && session[:org_code] != params[:org_code]
12
+ # reset_session
13
+ # end
13
14
  @org = MultiDB::Organization.active.where(:code => params[:org_code]).first
14
15
  end
15
16
 
@@ -28,18 +29,12 @@ class ActionController::Base
28
29
 
29
30
  if session[:org_code]
30
31
  @org ||= MultiDB::Organization.active.where(:code => session[:org_code]).first
31
- if @org
32
- ActiveRecord::Base.connect_to_organization(session[:org_code], true)
33
- return @org
34
- end
32
+ return @org if @org && @org.connect(true)
35
33
  end
36
34
 
37
35
  if Rails.env.test? && ENV['RAILS_ORG']
38
36
  @org ||= MultiDB::Organization.active.where(:code => ENV['RAILS_ORG']).first
39
- if @org
40
- ActiveRecord::Base.connect_to_organization(session[:org_code], true)
41
- return @org
42
- end
37
+ return @org if @org && @org.connect(true)
43
38
  end
44
39
 
45
40
  # if we don't issue an establish_connection by now, connect to default db (sessions)
@@ -231,7 +231,7 @@ db_namespace = namespace :db do
231
231
  require 'active_record/schema_dumper'
232
232
 
233
233
  databases_to_dump = case ENV['RAILS_ORG']
234
- when nil then [ :sessions, :master, :organization ]
234
+ when nil then [ :sessions, :master ]
235
235
  when 'sessions' then [ :sessions ]
236
236
  when 'master' then [ :master ]
237
237
  else [ :organization ]
data/multidb.gemspec CHANGED
@@ -4,7 +4,7 @@ $:.push File.expand_path("../lib", __FILE__)
4
4
  # Describe your gem and declare its dependencies:
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "multidb"
7
- s.version = '3.2.0'
7
+ s.version = '3.2.1'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.author = "Aaron Namba"
10
10
  s.email = "aaron@biggerbird.com"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multidb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Namba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-10 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: 1.8.11
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.2.0.rc.1
108
+ rubygems_version: 2.1.11
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: MultiDB for ActiveRecord