mongoid-tenant 0.0.9 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/tenant/tasks/tenant.rake +12 -4
- data/lib/mongoid/tenant/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da87610142cd33bf041973b6bbf3d4269b817bfb
|
4
|
+
data.tar.gz: e950140c0c210c811c4c495222271c0400e3c410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 529336cecc4d9e93407ecb068cacb7e2c2328beb0c7e9ee88273344b35f0f7a73bea479086735ec0285fca9ceb4153e567bc4fd0eb7c46fa7996a4fe68b56525
|
7
|
+
data.tar.gz: 68009a7a57bd79a0568b5a9264fe5c0e082b0cd1fcf6fa01561eb7f1b6fe3e042688e6dc61e2cef6546d81c2eea45d0ad802f0d680d264f33a14f625eb59ea0e
|
@@ -7,15 +7,23 @@ namespace :db do
|
|
7
7
|
ENV['TENANCY'] && !ENV['TENANCY'].empty? ? ENV['TENANCY'] : nil
|
8
8
|
end
|
9
9
|
|
10
|
+
def tenancy_models
|
11
|
+
::Mongoid.models.select { |k| k.include?(::Mongoid::Tenant) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def non_tenancy_models
|
15
|
+
::Mongoid.models.reject { |k| k.include?(::Mongoid::Tenant) }
|
16
|
+
end
|
17
|
+
|
10
18
|
desc 'Create Mongoid indexes, tenant aware'
|
11
19
|
task create_indexes: [:environment, :load_models] do
|
12
20
|
# Run once, for tables outside tenancy
|
13
|
-
::Mongoid::Tasks::Database.create_indexes
|
21
|
+
::Mongoid::Tasks::Database.create_indexes(non_tenancy_models)
|
14
22
|
if tenancy_env
|
15
23
|
Object.const_get(tenancy_env).all.each do |t|
|
16
24
|
puts "Tenant #{t}"
|
17
25
|
t.tenancy!
|
18
|
-
::Mongoid::Tasks::Database.create_indexes
|
26
|
+
::Mongoid::Tasks::Database.create_indexes(tenancy_models)
|
19
27
|
end
|
20
28
|
else
|
21
29
|
puts 'Not running tenants: Provide a tenancy model:'
|
@@ -26,12 +34,12 @@ namespace :db do
|
|
26
34
|
desc 'Removes undefined Mongoid indexes, tenant aware'
|
27
35
|
task remove_undefined_indexes: [:environment, :load_models] do
|
28
36
|
# Run once, for tables outside tenancy
|
29
|
-
::Mongoid::Tasks::Database.remove_undefined_indexes
|
37
|
+
::Mongoid::Tasks::Database.remove_undefined_indexes(non_tenancy_models)
|
30
38
|
if tenancy_env
|
31
39
|
Object.const_get(tenancy_env).all.each do |t|
|
32
40
|
puts "Tenant #{t}"
|
33
41
|
t.tenancy!
|
34
|
-
::Mongoid::Tasks::Database.remove_undefined_indexes
|
42
|
+
::Mongoid::Tasks::Database.remove_undefined_indexes(tenancy_models)
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-tenant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project: mongoid-tenant
|
72
|
-
rubygems_version: 2.
|
72
|
+
rubygems_version: 2.6.6
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Multiple databases Models for Mongoid documents.
|
@@ -78,4 +78,3 @@ test_files:
|
|
78
78
|
- spec/mongoid/tenant_spec.rb
|
79
79
|
- spec/spec_helper.rb
|
80
80
|
- spec/support/models.rb
|
81
|
-
has_rdoc:
|