rails_multisite 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rails_multisite might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +29 -2
- data/lib/rails_multisite.rb +1 -0
- data/lib/rails_multisite/connection_management.rb +4 -4
- data/lib/rails_multisite/formatter.rb +7 -0
- data/lib/rails_multisite/railtie.rb +1 -2
- data/lib/rails_multisite/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9125f561ab7f58fb9685d8a1ef7501add2dc2617
|
4
|
+
data.tar.gz: 6e1cda42fb46f76466b3828fd7f8a7c27054dc34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20bbec27a4d049bb250257bf6b3c3a354ff70617cac6eec973a1a64a8e888bea80ddfd9e169a1612d273059b20bb1400e22bbdd639c90e26d0c22ad80f5b4444
|
7
|
+
data.tar.gz: 37fa6cdbe00e7d32e20d8b10bac38e4f02350f3c6a2dd18f651c664caedebd3a8ea50e03143e0fcb57f7fb88b56a6f9063fd2af0b39eb69f7af0aad4824ad88e
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Using its middleware you can partition your app so each hostname has its own db.
|
|
6
6
|
|
7
7
|
It provides a series of helper for working with multiple database, and some additional rails tasks for working with them.
|
8
8
|
|
9
|
-
It was extracted from Discourse.
|
9
|
+
It was extracted from Discourse. https://discourse.org
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -26,8 +26,35 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
Configuration requires a file called: `config/multisite.yml` that specifies connection specs for all dbs.
|
28
28
|
|
29
|
+
```
|
30
|
+
mlp:
|
31
|
+
adapter: postgresql
|
32
|
+
database: discourse_mlp
|
33
|
+
username: discourse_mlp
|
34
|
+
password: applejack
|
35
|
+
host: dbhost
|
36
|
+
pool: 5
|
37
|
+
timeout: 5000
|
38
|
+
db_id: 1 # ensure db_id is unique for each site
|
39
|
+
host_names:
|
40
|
+
- discourse.equestria.com
|
41
|
+
- discourse.equestria.internal
|
42
|
+
|
43
|
+
drwho:
|
44
|
+
adapter: postgresql
|
45
|
+
database: discourse_who
|
46
|
+
username: discourse_who
|
47
|
+
password: "Up the time stream without a TARDIS"
|
48
|
+
host: dbhost
|
49
|
+
pool: 5
|
50
|
+
timeout: 5000
|
51
|
+
db_id: 2# ensure db_id is unique for each site
|
52
|
+
host_names:
|
53
|
+
- discuss.tardis.gallifrey
|
54
|
+
```
|
55
|
+
|
29
56
|
|
30
|
-
###
|
57
|
+
### Execute a query on each connection
|
31
58
|
|
32
59
|
```
|
33
60
|
RailsMultisite::ConnectionManagement.each_connection do |db|
|
data/lib/rails_multisite.rb
CHANGED
@@ -61,7 +61,7 @@ module RailsMultisite
|
|
61
61
|
rval
|
62
62
|
end
|
63
63
|
|
64
|
-
def self.with_connection(db =
|
64
|
+
def self.with_connection(db = DEFAULT)
|
65
65
|
old = current_db
|
66
66
|
connected = ActiveRecord::Base.connection_pool.connected?
|
67
67
|
|
@@ -137,7 +137,7 @@ module RailsMultisite
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def self.all_dbs
|
140
|
-
[
|
140
|
+
[DEFAULT] +
|
141
141
|
if defined?(@@db_spec_cache) && @@db_spec_cache
|
142
142
|
@@db_spec_cache.keys.to_a
|
143
143
|
else
|
@@ -146,7 +146,7 @@ module RailsMultisite
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def self.current_db
|
149
|
-
ActiveRecord::Base.connection_pool.spec.config[:db_key] ||
|
149
|
+
ActiveRecord::Base.connection_pool.spec.config[:db_key] || DEFAULT
|
150
150
|
end
|
151
151
|
|
152
152
|
def self.config_filename=(config_filename)
|
@@ -175,7 +175,7 @@ module RailsMultisite
|
|
175
175
|
no_prepared_statements = ActiveRecord::Base.configurations[Rails.env]["prepared_statements"] == false
|
176
176
|
|
177
177
|
configs.each do |k,v|
|
178
|
-
raise ArgumentError.new("Please do not name any db default!") if k ==
|
178
|
+
raise ArgumentError.new("Please do not name any db default!") if k == DEFAULT
|
179
179
|
v[:db_key] = k
|
180
180
|
v[:prepared_statements] = false if no_prepared_statements
|
181
181
|
end
|
@@ -8,6 +8,7 @@ module RailsMultisite
|
|
8
8
|
Rails.configuration.multisite = false
|
9
9
|
if File.exists?(ConnectionManagement.config_filename)
|
10
10
|
Rails.configuration.multisite = true
|
11
|
+
Rails.logger.formatter = RailsMultisite::Formatter.new
|
11
12
|
ConnectionManagement.load_settings!
|
12
13
|
app.middleware.insert_after(ActiveRecord::ConnectionAdapters::ConnectionManagement, RailsMultisite::ConnectionManagement)
|
13
14
|
app.middleware.delete(ActiveRecord::ConnectionAdapters::ConnectionManagement)
|
@@ -16,8 +17,6 @@ module RailsMultisite
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
19
|
-
|
20
|
-
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_multisite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Multi tenancy support for Rails
|
14
14
|
email:
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- README.md
|
22
22
|
- lib/rails_multisite.rb
|
23
23
|
- lib/rails_multisite/connection_management.rb
|
24
|
+
- lib/rails_multisite/formatter.rb
|
24
25
|
- lib/rails_multisite/railtie.rb
|
25
26
|
- lib/rails_multisite/version.rb
|
26
27
|
- lib/tasks/db.rake
|
@@ -44,8 +45,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
45
|
version: '0'
|
45
46
|
requirements: []
|
46
47
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.
|
48
|
+
rubygems_version: 2.5.1
|
48
49
|
signing_key:
|
49
50
|
specification_version: 4
|
50
51
|
summary: Multi tenancy support for Rails
|
51
52
|
test_files: []
|
53
|
+
has_rdoc:
|