Commit b20423af0807d3d23501a916b371b9363ee484c2
Exists in
master
and in
29 other branches
Merge remote-tracking branch 'origin/master'
Showing
3 changed files
with
8 additions
and
8 deletions
Show diff stats
INSTALL.multitenancy.md
@@ -26,7 +26,7 @@ The file config/database.yml must follow a structure in order to achieve multite | @@ -26,7 +26,7 @@ The file config/database.yml must follow a structure in order to achieve multite | ||
26 | 26 | ||
27 | Each "hosted" environment must have an entry like this: | 27 | Each "hosted" environment must have an entry like this: |
28 | 28 | ||
29 | - env1_production: | 29 | + env1_production: &DEFAULT |
30 | adapter: postgresql | 30 | adapter: postgresql |
31 | encoding: unicode | 31 | encoding: unicode |
32 | database: noosfero | 32 | database: noosfero |
@@ -61,7 +61,7 @@ The "hosted" environments define, besides the `schema_search_path`, a list of do | @@ -61,7 +61,7 @@ The "hosted" environments define, besides the `schema_search_path`, a list of do | ||
61 | You must also tell the application which is the default environment. | 61 | You must also tell the application which is the default environment. |
62 | 62 | ||
63 | production: | 63 | production: |
64 | - env1_production | 64 | + <<: *DEFAULT |
65 | 65 | ||
66 | On the example above there are only three hosted environments, but it can be more than three. The schemas `env2` and `env3` must already exist in the same database of the hosting environment. As postgres user, you can create them typing: | 66 | On the example above there are only three hosted environments, but it can be more than three. The schemas `env2` and `env3` must already exist in the same database of the hosting environment. As postgres user, you can create them typing: |
67 | 67 |
config/database.yml.multitenancy
1 | # Refer to INSTALL.multitenancy for more information on Multitenancy support | 1 | # Refer to INSTALL.multitenancy for more information on Multitenancy support |
2 | -env1_production: | 2 | +env1_production: &DEFAULT |
3 | adapter: postgresql | 3 | adapter: postgresql |
4 | encoding: unicode | 4 | encoding: unicode |
5 | database: noosfero | 5 | database: noosfero |
@@ -30,4 +30,4 @@ env3_production: | @@ -30,4 +30,4 @@ env3_production: | ||
30 | - env3.net | 30 | - env3.net |
31 | 31 | ||
32 | production: | 32 | production: |
33 | - env1_production | 33 | + <<: *DEFAULT |
lib/tasks/multitenancy.rake
1 | namespace :multitenancy do | 1 | namespace :multitenancy do |
2 | 2 | ||
3 | - task :create do | 3 | + task :create => :environment do |
4 | db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } | 4 | db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } |
5 | cd Rails.root.join('config', 'environments'), :verbose => true | 5 | cd Rails.root.join('config', 'environments'), :verbose => true |
6 | - file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" | 6 | + file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}" |
7 | (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env } | 7 | (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env } |
8 | end | 8 | end |
9 | 9 | ||
10 | - task :remove do | 10 | + task :remove => :environment do |
11 | db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } | 11 | db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } |
12 | cd Rails.root.join('config', 'environments'), :verbose => true | 12 | cd Rails.root.join('config', 'environments'), :verbose => true |
13 | - file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" | 13 | + file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}" |
14 | (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env } | 14 | (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env } |
15 | end | 15 | end |
16 | 16 |