ros-apartment 2.9.0 → 2.11.0

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
  SHA256:
3
- metadata.gz: f31fef7b2332c76bce3bff4823754c145b7a049bbf845ce29bb22b65b29585e4
4
- data.tar.gz: 657b9a8bf128f912894e03bd2331b2e2201bf9f43f38515117e434ef65694341
3
+ metadata.gz: 6182f5dcd4e369e6f497295705079b3d0b20d644d8006c5a256d8618eff1a2c3
4
+ data.tar.gz: 351be335f73230dd83df3020ba77b33f8e33e297f67c5256210f3e0c0c12e749
5
5
  SHA512:
6
- metadata.gz: d35580a7ed02ea8423251e0e7ed555d002fe34f4d2705cb16b982e5211a5f79fd8f078b97c7ac633f8b1bb605c9ada8176a6c082c0d1ad00591ba4b079acb7b4
7
- data.tar.gz: fa77558d5731e0a99c8ff1f8611c5353e633a5bbcd37fe94c64fe310414f8f724177d6fa7121ca88031315638990087546892a7411fd7477e37362de52682e31
6
+ metadata.gz: 7714a5182a47cefc6a95d85118278263bf4d326c5441184005a3ef48cf10368cd123602a0e5635547233c12ecb587e107dc72c0a117423dd774054f19767e3ce
7
+ data.tar.gz: 6b4247215b4754d031ce248f6e457d1c509157d310964e74cc72f05e8f896215b29341cd892515c9e9803a2f0db6528f180474b0c14cf03384ee1ac4f9693164
data/.circleci/config.yml CHANGED
@@ -1,8 +1,5 @@
1
1
  version: 2.1
2
2
 
3
- orbs:
4
- rubocop: hanachin/rubocop@0.0.6
5
-
6
3
  jobs:
7
4
  build:
8
5
  docker:
@@ -61,7 +58,10 @@ jobs:
61
58
 
62
59
  - run:
63
60
  name: Run tests
64
- command: bundle exec rspec
61
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/test-results/rspec/rspec.xml
62
+
63
+ - store_test_results:
64
+ path: ~/test-results/rspec/
65
65
 
66
66
  workflows:
67
67
  tests:
@@ -69,10 +69,10 @@ workflows:
69
69
  - build:
70
70
  matrix:
71
71
  parameters:
72
- ruby_version: ["ruby:2.6-buster", "ruby:2.7-buster"]
73
- gemfile: ["gemfiles/rails_5_2.gemfile", "gemfiles/rails_6_0.gemfile", "gemfiles/rails_6_1.gemfile"]
74
-
75
- rubocop:
76
- jobs:
77
- - rubocop/rubocop:
78
- version: 0.88.0
72
+ ruby_version: ["ruby:2.6-buster", "ruby:2.7-buster", "ruby:3.0-buster"]
73
+ gemfile: ["gemfiles/rails_5_2.gemfile", "gemfiles/rails_6_0.gemfile", "gemfiles/rails_6_1.gemfile", "gemfiles/rails_7_0.gemfile"]
74
+ exclude:
75
+ - ruby_version: "ruby:3.0-buster"
76
+ gemfile: "gemfiles/rails_5_2.gemfile"
77
+ - ruby_version: "ruby:2.6-buster"
78
+ gemfile: "gemfiles/rails_7_0.gemfile"
@@ -0,0 +1,22 @@
1
+ name: reviewdog
2
+ on: [push, pull_request]
3
+ jobs:
4
+ rubocop:
5
+ name: runner / rubocop
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Check out code
9
+ uses: actions/checkout@v2
10
+ - name: Read ruby version
11
+ run: echo ::set-output name=RUBY_VERSION::$(cat .ruby-version | cut -f 1,2 -d .)
12
+ id: rv
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: "${{ steps.rv.outputs.RUBY_VERSION }}"
16
+ - uses: reviewdog/action-rubocop@v1
17
+ with:
18
+ filter_mode: nofilter
19
+ reporter: github-check
20
+ rubocop_version: 0.93.1
21
+ github_token: ${{ secrets.github_token }}
22
+ rubocop_extensions: rubocop-performance:1.10.2 rubocop-rails:2.9.1 rubocop-rspec:1.44.1
data/.rubocop.yml CHANGED
@@ -1,96 +1,32 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- AllCops:
4
- Exclude:
5
- - 'gemfiles/**/*.gemfile'
6
- - 'gemfiles/vendor/**/*'
7
- - 'spec/dummy_engine/dummy_engine.gemspec'
8
-
9
- Gemspec/RequiredRubyVersion:
10
- Exclude:
11
- - 'ros-apartment.gemspec'
3
+ require:
4
+ - rubocop-rails
5
+ - rubocop-performance
6
+ - rubocop-rspec
12
7
 
13
- Style/WordArray:
8
+ AllCops:
14
9
  Exclude:
10
+ - gemfiles/**/*.gemfile
11
+ - gemfiles/vendor/**/*
12
+ - spec/dummy_engine/dummy_engine.gemspec
15
13
  - spec/schemas/**/*.rb
16
14
 
17
- Style/NumericLiterals:
18
- Exclude:
19
- - spec/schemas/**/*.rb
15
+ NewCops: enable
20
16
 
21
- Layout/EmptyLineAfterMagicComment:
17
+ Gemspec/RequiredRubyVersion:
22
18
  Exclude:
23
- - spec/schemas/**/*.rb
19
+ - 'ros-apartment.gemspec'
24
20
 
25
21
  Metrics/BlockLength:
26
22
  Exclude:
27
23
  - spec/**/*.rb
28
24
 
29
- Layout/EmptyLinesAroundAttributeAccessor:
30
- Enabled: true
31
-
32
- Layout/SpaceAroundMethodCallOperator:
33
- Enabled: true
34
-
35
- Lint/DeprecatedOpenSSLConstant:
36
- Enabled: true
37
-
38
- Lint/DuplicateElsifCondition:
39
- Enabled: true
40
-
41
- Lint/MixedRegexpCaptureTypes:
42
- Enabled: true
43
-
44
- Lint/RaiseException:
45
- Enabled: true
46
-
47
- Lint/StructNewOverride:
48
- Enabled: true
49
-
50
- Style/AccessorGrouping:
51
- Enabled: true
52
-
53
- Style/ArrayCoercion:
54
- Enabled: true
55
-
56
- Style/BisectedAttrAccessor:
57
- Enabled: true
58
-
59
- Style/CaseLikeIf:
60
- Enabled: true
61
-
62
- Style/ExponentialNotation:
63
- Enabled: true
64
-
65
- Style/HashAsLastArrayItem:
66
- Enabled: true
67
-
68
- Style/HashEachMethods:
69
- Enabled: true
70
-
71
- Style/HashLikeCase:
72
- Enabled: true
73
-
74
- Style/HashTransformKeys:
75
- Enabled: true
76
-
77
- Style/HashTransformValues:
78
- Enabled: true
79
-
80
- Style/RedundantAssignment:
81
- Enabled: true
82
-
83
- Style/RedundantFetchBlock:
84
- Enabled: true
85
-
86
- Style/RedundantFileExtensionInRequire:
87
- Enabled: true
88
-
89
- Style/RedundantRegexpCharacterClass:
90
- Enabled: true
25
+ Rails/RakeEnvironment:
26
+ Enabled: false
91
27
 
92
- Style/RedundantRegexpEscape:
93
- Enabled: true
28
+ Rails/ApplicationRecord:
29
+ Enabled: false
94
30
 
95
- Style/SlicingWithRange:
96
- Enabled: true
31
+ Rails/Output:
32
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-07-16 04:15:41 UTC using RuboCop version 0.88.0.
3
+ # on 2021-06-26 03:25:28 UTC using RuboCop version 0.93.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -11,22 +11,16 @@ Lint/MixedRegexpCaptureTypes:
11
11
  Exclude:
12
12
  - 'lib/apartment/elevators/domain.rb'
13
13
 
14
- # Offense count: 2
15
- # Cop supports --auto-correct.
16
- Lint/NonDeterministicRequireOrder:
17
- Exclude:
18
- - 'spec/spec_helper.rb'
19
-
20
- # Offense count: 7
14
+ # Offense count: 3
21
15
  # Configuration parameters: IgnoredMethods.
22
16
  Metrics/AbcSize:
23
- Max: 33
17
+ Max: 28
24
18
 
25
- # Offense count: 3
19
+ # Offense count: 5
26
20
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
27
21
  # ExcludedMethods: refine
28
22
  Metrics/BlockLength:
29
- Max: 102
23
+ Max: 83
30
24
 
31
25
  # Offense count: 1
32
26
  # Configuration parameters: CountComments, CountAsOne.
@@ -38,6 +32,188 @@ Metrics/ClassLength:
38
32
  Metrics/MethodLength:
39
33
  Max: 24
40
34
 
35
+ # Offense count: 3
36
+ RSpec/AnyInstance:
37
+ Exclude:
38
+ - 'spec/unit/migrator_spec.rb'
39
+
40
+ # Offense count: 2
41
+ RSpec/BeforeAfterAll:
42
+ Exclude:
43
+ - 'spec/spec_helper.rb'
44
+ - 'spec/rails_helper.rb'
45
+ - 'spec/support/**/*.rb'
46
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
47
+ - 'spec/tasks/apartment_rake_spec.rb'
48
+
49
+ # Offense count: 18
50
+ # Configuration parameters: Prefixes.
51
+ # Prefixes: when, with, without
52
+ RSpec/ContextWording:
53
+ Exclude:
54
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
55
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
56
+ - 'spec/examples/schema_adapter_examples.rb'
57
+ - 'spec/support/contexts.rb'
58
+ - 'spec/tasks/apartment_rake_spec.rb'
59
+ - 'spec/tenant_spec.rb'
60
+
61
+ # Offense count: 4
62
+ # Configuration parameters: IgnoredMetadata.
63
+ RSpec/DescribeClass:
64
+ Exclude:
65
+ - 'spec/integration/apartment_rake_integration_spec.rb'
66
+ - 'spec/integration/query_caching_spec.rb'
67
+ - 'spec/integration/use_within_an_engine_spec.rb'
68
+ - 'spec/tasks/apartment_rake_spec.rb'
69
+
70
+ # Offense count: 12
71
+ # Cop supports --auto-correct.
72
+ # Configuration parameters: SkipBlocks, EnforcedStyle.
73
+ # SupportedStyles: described_class, explicit
74
+ RSpec/DescribedClass:
75
+ Exclude:
76
+ - 'spec/apartment_spec.rb'
77
+ - 'spec/tenant_spec.rb'
78
+ - 'spec/unit/elevators/host_hash_spec.rb'
79
+ - 'spec/unit/migrator_spec.rb'
80
+
81
+ # Offense count: 5
82
+ # Cop supports --auto-correct.
83
+ RSpec/EmptyLineAfterFinalLet:
84
+ Exclude:
85
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
86
+ - 'spec/examples/schema_adapter_examples.rb'
87
+
88
+ # Offense count: 14
89
+ # Configuration parameters: Max.
90
+ RSpec/ExampleLength:
91
+ Exclude:
92
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
93
+ - 'spec/examples/generic_adapter_examples.rb'
94
+ - 'spec/examples/schema_adapter_examples.rb'
95
+ - 'spec/integration/query_caching_spec.rb'
96
+ - 'spec/tenant_spec.rb'
97
+
98
+ # Offense count: 60
99
+ # Cop supports --auto-correct.
100
+ # Configuration parameters: CustomTransform, IgnoredWords.
101
+ RSpec/ExampleWording:
102
+ Exclude:
103
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
104
+ - 'spec/apartment_spec.rb'
105
+ - 'spec/examples/connection_adapter_examples.rb'
106
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
107
+ - 'spec/examples/generic_adapter_examples.rb'
108
+ - 'spec/examples/schema_adapter_examples.rb'
109
+ - 'spec/integration/apartment_rake_integration_spec.rb'
110
+ - 'spec/integration/use_within_an_engine_spec.rb'
111
+ - 'spec/tasks/apartment_rake_spec.rb'
112
+ - 'spec/tenant_spec.rb'
113
+
114
+ # Offense count: 13
115
+ # Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
116
+ RSpec/FilePath:
117
+ Exclude:
118
+ - 'spec/adapters/mysql2_adapter_spec.rb'
119
+ - 'spec/adapters/postgresql_adapter_spec.rb'
120
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
121
+ - 'spec/tenant_spec.rb'
122
+ - 'spec/unit/config_spec.rb'
123
+ - 'spec/unit/elevators/domain_spec.rb'
124
+ - 'spec/unit/elevators/first_subdomain_spec.rb'
125
+ - 'spec/unit/elevators/generic_spec.rb'
126
+ - 'spec/unit/elevators/host_hash_spec.rb'
127
+ - 'spec/unit/elevators/host_spec.rb'
128
+ - 'spec/unit/elevators/subdomain_spec.rb'
129
+ - 'spec/unit/migrator_spec.rb'
130
+
131
+ # Offense count: 1
132
+ # Cop supports --auto-correct.
133
+ # Configuration parameters: EnforcedStyle.
134
+ # SupportedStyles: implicit, each, example
135
+ RSpec/HookArgument:
136
+ Exclude:
137
+ - 'spec/support/setup.rb'
138
+
139
+ # Offense count: 4
140
+ # Cop supports --auto-correct.
141
+ RSpec/HooksBeforeExamples:
142
+ Exclude:
143
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
144
+ - 'spec/examples/schema_adapter_examples.rb'
145
+
146
+ # Offense count: 18
147
+ # Configuration parameters: AssignmentOnly.
148
+ RSpec/InstanceVariable:
149
+ Exclude:
150
+ - 'spec/examples/generic_adapter_examples.rb'
151
+ - 'spec/examples/schema_adapter_examples.rb'
152
+ - 'spec/integration/apartment_rake_integration_spec.rb'
153
+ - 'spec/integration/use_within_an_engine_spec.rb'
154
+ - 'spec/tasks/apartment_rake_spec.rb'
155
+
156
+ # Offense count: 1
157
+ # Cop supports --auto-correct.
158
+ RSpec/LeadingSubject:
159
+ Exclude:
160
+
161
+ # Offense count: 2
162
+ RSpec/LeakyConstantDeclaration:
163
+ Exclude:
164
+ - 'spec/examples/generic_adapters_callbacks_examples.rb'
165
+ - 'spec/unit/elevators/generic_spec.rb'
166
+
167
+ # Offense count: 35
168
+ # Configuration parameters: EnforcedStyle.
169
+ # SupportedStyles: have_received, receive
170
+ RSpec/MessageSpies:
171
+ Exclude:
172
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
173
+ - 'spec/integration/apartment_rake_integration_spec.rb'
174
+ - 'spec/integration/use_within_an_engine_spec.rb'
175
+ - 'spec/tasks/apartment_rake_spec.rb'
176
+ - 'spec/unit/elevators/domain_spec.rb'
177
+ - 'spec/unit/elevators/generic_spec.rb'
178
+ - 'spec/unit/elevators/host_hash_spec.rb'
179
+ - 'spec/unit/elevators/host_spec.rb'
180
+ - 'spec/unit/elevators/subdomain_spec.rb'
181
+ - 'spec/unit/migrator_spec.rb'
182
+
183
+ # Offense count: 29
184
+ RSpec/MultipleExpectations:
185
+ Max: 4
186
+
187
+ # Offense count: 47
188
+ # Configuration parameters: IgnoreSharedExamples.
189
+ RSpec/NamedSubject:
190
+ Exclude:
191
+ - 'spec/adapters/mysql2_adapter_spec.rb'
192
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
193
+ - 'spec/support/contexts.rb'
194
+ - 'spec/support/requirements.rb'
195
+ - 'spec/tenant_spec.rb'
196
+
197
+ # Offense count: 24
198
+ RSpec/NestedGroups:
199
+ Max: 5
200
+
201
+ # Offense count: 6
202
+ # Cop supports --auto-correct.
203
+ # Configuration parameters: EnforcedStyle.
204
+ # SupportedStyles: and_return, block
205
+ RSpec/ReturnFromStub:
206
+ Exclude:
207
+ - 'spec/integration/apartment_rake_integration_spec.rb'
208
+ - 'spec/unit/migrator_spec.rb'
209
+
210
+ # Offense count: 4
211
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
212
+ RSpec/VerifiedDoubles:
213
+ Exclude:
214
+ - 'spec/integration/apartment_rake_integration_spec.rb'
215
+ - 'spec/unit/elevators/first_subdomain_spec.rb'
216
+
41
217
  # Offense count: 17
42
218
  Style/Documentation:
43
219
  Exclude:
@@ -52,15 +228,6 @@ Style/Documentation:
52
228
  - 'lib/apartment/migrator.rb'
53
229
  - 'lib/apartment/model.rb'
54
230
  - 'lib/apartment/railtie.rb'
55
- - 'lib/apartment/reloader.rb'
56
231
  - 'lib/apartment/tasks/enhancements.rb'
57
232
  - 'lib/apartment/tasks/task_helper.rb'
58
233
  - 'lib/generators/apartment/install/install_generator.rb'
59
-
60
- # Offense count: 3
61
- # Cop supports --auto-correct.
62
- Style/IfUnlessModifier:
63
- Exclude:
64
- - 'Rakefile'
65
- - 'lib/apartment.rb'
66
- - 'lib/apartment/tenant.rb'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.5
data/Appraisals CHANGED
@@ -1,29 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'rails-5-0' do
4
- gem 'rails', '~> 5.0.0'
5
- platforms :ruby do
6
- gem 'pg', '< 1.0.0'
7
- end
8
- platforms :jruby do
9
- gem 'activerecord-jdbc-adapter', '~> 50.0'
10
- gem 'activerecord-jdbcpostgresql-adapter', '~> 50.0'
11
- gem 'activerecord-jdbcmysql-adapter', '~> 50.0'
12
- end
13
- end
14
-
15
- appraise 'rails-5-1' do
16
- gem 'rails', '~> 5.1.0'
17
- platforms :ruby do
18
- gem 'pg', '< 1.0.0'
19
- end
20
- platforms :jruby do
21
- gem 'activerecord-jdbc-adapter', '~> 51.0'
22
- gem 'activerecord-jdbcpostgresql-adapter', '~> 51.0'
23
- gem 'activerecord-jdbcmysql-adapter', '~> 51.0'
24
- end
25
- end
26
-
27
3
  appraise 'rails-5-2' do
28
4
  gem 'rails', '~> 5.2.0'
29
5
  platforms :jruby do
@@ -57,6 +33,18 @@ appraise 'rails-6-1' do
57
33
  end
58
34
  end
59
35
 
36
+ appraise 'rails-7-0' do
37
+ gem 'rails', '~> 7.0.0'
38
+ platforms :ruby do
39
+ gem 'sqlite3', '~> 1.4'
40
+ end
41
+ platforms :jruby do
42
+ gem 'activerecord-jdbc-adapter', '~> 61.0'
43
+ gem 'activerecord-jdbcpostgresql-adapter', '~> 61.0'
44
+ gem 'activerecord-jdbcmysql-adapter', '~> 61.0'
45
+ end
46
+ end
47
+
60
48
  appraise 'rails-master' do
61
49
  gem 'rails', git: 'https://github.com/rails/rails.git'
62
50
  platforms :ruby do
data/Gemfile CHANGED
@@ -3,11 +3,3 @@
3
3
  source 'http://rubygems.org'
4
4
 
5
5
  gemspec
6
-
7
- gem 'rails', '>= 3.1.2'
8
- gem 'rubocop'
9
-
10
- group :local do
11
- gem 'guard-rspec', '~> 4.2'
12
- gem 'pry'
13
- end
data/README.md CHANGED
@@ -101,6 +101,16 @@ switched back at the end of the block to what it was before.
101
101
  There is also `switch!` which doesn't take a block, but it's recommended to use `switch`.
102
102
  To return to the default tenant, you can call `switch` with no arguments.
103
103
 
104
+ #### Multiple Tenants
105
+
106
+ When using schemas, you can also pass in a list of schemas if desired. Any tables defined in a schema earlier in the chain will be referenced first, so this is only useful if you have a schema with only some of the tables defined:
107
+
108
+ ```ruby
109
+ Apartment::Tenant.switch(['tenant_1', 'tenant_2']) do
110
+ # ...
111
+ end
112
+ ```
113
+
104
114
  ### Switching Tenants per request
105
115
 
106
116
  You can have Apartment route to the appropriate tenant by adding some Rack middleware.
@@ -334,7 +344,7 @@ Setting this configuration value to `false` will disable the schema presence che
334
344
 
335
345
  ```ruby
336
346
  Apartment.configure do |config|
337
- tenant_presence_check = false
347
+ config.tenant_presence_check = false
338
348
  end
339
349
  ```
340
350
 
@@ -3,12 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.2.0"
6
- gem "rubocop"
7
-
8
- group :local do
9
- gem "guard-rspec", "~> 4.2"
10
- gem "pry"
11
- end
12
6
 
13
7
  platforms :jruby do
14
8
  gem "activerecord-jdbc-adapter", "~> 52.0"
@@ -3,12 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 6.0.0"
6
- gem "rubocop"
7
-
8
- group :local do
9
- gem "guard-rspec", "~> 4.2"
10
- gem "pry"
11
- end
12
6
 
13
7
  platforms :ruby do
14
8
  gem "sqlite3", "~> 1.4"
@@ -3,12 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 6.1.0"
6
- gem "rubocop"
7
-
8
- group :local do
9
- gem "guard-rspec", "~> 4.2"
10
- gem "pry"
11
- end
12
6
 
13
7
  platforms :ruby do
14
8
  gem "sqlite3", "~> 1.4"
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 7.0.0"
6
+
7
+ platforms :ruby do
8
+ gem "sqlite3", "~> 1.4"
9
+ end
10
+
11
+ platforms :jruby do
12
+ gem "activerecord-jdbc-adapter", "~> 61.0"
13
+ gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
14
+ gem "activerecord-jdbcmysql-adapter", "~> 61.0"
15
+ end
16
+
17
+ gemspec path: "../"
@@ -3,21 +3,15 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", git: "https://github.com/rails/rails.git"
6
- gem "rubocop"
7
-
8
- group :local do
9
- gem "guard-rspec", "~> 4.2"
10
- gem "pry"
11
- end
12
6
 
13
7
  platforms :ruby do
14
8
  gem "sqlite3", "~> 1.4"
15
9
  end
16
10
 
17
11
  platforms :jruby do
18
- gem "activerecord-jdbc-adapter", "~> 52.0"
19
- gem "activerecord-jdbcpostgresql-adapter", "~> 52.0"
20
- gem "activerecord-jdbcmysql-adapter", "~> 52.0"
12
+ gem "activerecord-jdbc-adapter", "~> 61.0"
13
+ gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
14
+ gem "activerecord-jdbcmysql-adapter", "~> 61.0"
21
15
  end
22
16
 
23
17
  gemspec path: "../"
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+
5
+ # NOTE: This patch is meant to remove any schema_prefix appart from the ones for
6
+ # excluded models. The schema_prefix would be resolved by apartment's setting
7
+ # of search path
8
+ module Apartment::PostgreSqlAdapterPatch
9
+ def default_sequence_name(table, _column)
10
+ res = super
11
+ schema_prefix = "#{Apartment::Tenant.current}."
12
+ default_tenant_prefix = "#{Apartment::Tenant.default_tenant}."
13
+
14
+ # NOTE: Excluded models should always access the sequence from the default
15
+ # tenant schema
16
+ if excluded_model?(table)
17
+ res.sub!(schema_prefix, default_tenant_prefix) if schema_prefix != default_tenant_prefix
18
+ return res
19
+ end
20
+
21
+ res.delete_prefix!(schema_prefix) if res&.starts_with?(schema_prefix)
22
+
23
+ res
24
+ end
25
+
26
+ private
27
+
28
+ def excluded_model?(table)
29
+ Apartment.excluded_models.any? { |m| m.constantize.table_name == table }
30
+ end
31
+ end
32
+
33
+ require 'active_record/connection_adapters/postgresql_adapter'
34
+
35
+ # NOTE: inject this into postgresql adapters
36
+ class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
37
+ include Apartment::PostgreSqlAdapterPatch
38
+ end
39
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -38,11 +38,9 @@ module Apartment
38
38
  #
39
39
  def connect_to_new(tenant = nil)
40
40
  return reset if tenant.nil?
41
+ raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless schema_exists?(tenant)
41
42
 
42
- tenant = tenant.to_s
43
- raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant)
44
-
45
- @current = tenant
43
+ @current = tenant.is_a?(Array) ? tenant.map(&:to_s) : tenant.to_s
46
44
  Apartment.connection.schema_search_path = full_search_path
47
45
  rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError
48
46
  raise TenantNotFound, "One of the following schema(s) is invalid: #{full_search_path}"
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'apartment/adapters/abstract_adapter'
4
+ require 'apartment/active_record/postgresql_adapter'
4
5
 
5
6
  module Apartment
6
7
  module Tenant
@@ -41,7 +42,6 @@ module Apartment
41
42
  def reset
42
43
  @current = default_tenant
43
44
  Apartment.connection.schema_search_path = full_search_path
44
- reset_sequence_names
45
45
  end
46
46
 
47
47
  def init
@@ -72,20 +72,17 @@ module Apartment
72
72
  #
73
73
  def connect_to_new(tenant = nil)
74
74
  return reset if tenant.nil?
75
+ raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless schema_exists?(tenant)
75
76
 
76
- tenant = tenant.to_s
77
- raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant)
78
-
79
- @current = tenant
77
+ @current = tenant.is_a?(Array) ? tenant.map(&:to_s) : tenant.to_s
80
78
  Apartment.connection.schema_search_path = full_search_path
81
79
 
82
80
  # When the PostgreSQL version is < 9.3,
83
81
  # there is a issue for prepared statement with changing search_path.
84
82
  # https://www.postgresql.org/docs/9.3/static/sql-prepare.html
85
83
  Apartment.connection.clear_cache! if postgresql_version < 90_300
86
- reset_sequence_names
87
- rescue *rescuable_exceptions
88
- raise TenantNotFound, "One of the following schema(s) is invalid: \"#{tenant}\" #{full_search_path}"
84
+ rescue *rescuable_exceptions => e
85
+ raise_schema_connect_to_new(tenant, e)
89
86
  end
90
87
 
91
88
  private
@@ -132,22 +129,17 @@ module Apartment
132
129
  Apartment.connection.send(:postgresql_version)
133
130
  end
134
131
 
135
- def reset_sequence_names
136
- # sequence_name contains the schema, so it must be reset after switch
137
- # There is `reset_sequence_name`, but that method actually goes to the database
138
- # to find out the new name. Therefore, we do this hack to only unset the name,
139
- # and it will be dynamically found the next time it is needed
140
- descendants_to_unset = ActiveRecord::Base.descendants
141
- .select { |c| c.instance_variable_defined?(:@sequence_name) }
142
- .reject do |c|
143
- c.instance_variable_defined?(:@explicit_sequence_name) &&
144
- c.instance_variable_get(:@explicit_sequence_name)
145
- end
146
- descendants_to_unset.each do |c|
147
- # NOTE: due to this https://github.com/rails-on-services/apartment/issues/81
148
- # unreproduceable error we're checking before trying to remove it
149
- c.remove_instance_variable :@sequence_name if c.instance_variable_defined?(:@sequence_name)
150
- end
132
+ def schema_exists?(schemas)
133
+ return true unless Apartment.tenant_presence_check
134
+
135
+ Array(schemas).all? { |schema| Apartment.connection.schema_exists?(schema.to_s) }
136
+ end
137
+
138
+ def raise_schema_connect_to_new(tenant, exception)
139
+ raise TenantNotFound, <<~EXCEPTION_MESSAGE
140
+ Could not set search path to schemas, they may be invalid: "#{tenant}" #{full_search_path}.
141
+ Original error: #{exception.class}: #{exception}
142
+ EXCEPTION_MESSAGE
151
143
  end
152
144
  end
153
145
 
@@ -158,6 +150,7 @@ module Apartment
158
150
  /SET lock_timeout/i, # new in postgresql 9.3
159
151
  /SET row_security/i, # new in postgresql 9.5
160
152
  /SET idle_in_transaction_session_timeout/i, # new in postgresql 9.6
153
+ /SET default_table_access_method/i, # new in postgresql 12
161
154
  /CREATE SCHEMA public/i,
162
155
  /COMMENT ON SCHEMA public/i
163
156
 
@@ -224,7 +217,7 @@ module Apartment
224
217
 
225
218
  # Temporary set Postgresql related environment variables if there are in @config
226
219
  #
227
- def with_pg_env(&block)
220
+ def with_pg_env
228
221
  pghost = ENV['PGHOST']
229
222
  pgport = ENV['PGPORT']
230
223
  pguser = ENV['PGUSER']
@@ -235,7 +228,7 @@ module Apartment
235
228
  ENV['PGUSER'] = @config[:username].to_s if @config[:username]
236
229
  ENV['PGPASSWORD'] = @config[:password].to_s if @config[:password]
237
230
 
238
- block.call
231
+ yield
239
232
  ensure
240
233
  ENV['PGHOST'] = pghost
241
234
  ENV['PGPORT'] = pgport
@@ -1,21 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # A workaround to get `reload!` to also call Apartment::Tenant.init
4
- # This is unfortunate, but I haven't figured out how to hook into the reload process *after* files are reloaded
5
-
6
- # reloads the environment
7
- # rubocop:disable Style/OptionalBooleanParameter
8
- def reload!(print = true)
9
- puts 'Reloading...' if print
10
-
11
- # This triggers the to_prepare callbacks
12
- ActionDispatch::Callbacks.new(proc {}).call({})
13
- # Manually init Apartment again once classes are reloaded
14
- Apartment::Tenant.init
15
- true
16
- end
17
- # rubocop:enable Style/OptionalBooleanParameter
18
-
19
3
  def st(schema_name = nil)
20
4
  if schema_name.nil?
21
5
  tenant_list.each { |t| puts t }
@@ -17,7 +17,9 @@ module Apartment
17
17
  cache_key = if key.is_a? String
18
18
  "#{Apartment::Tenant.current}_#{key}"
19
19
  else
20
- [Apartment::Tenant.current] + key
20
+ # NOTE: In Rails 6.0.4 we start receiving an ActiveRecord::Reflection::BelongsToReflection
21
+ # as the key, which wouldn't work well with an array.
22
+ [Apartment::Tenant.current] + Array.wrap(key)
21
23
  end
22
24
  cache = @find_by_statement_cache[connection.prepared_statements]
23
25
  cache.compute_if_absent(cache_key) { ActiveRecord::StatementCache.create(connection, &block) }
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'rails'
4
4
  require 'apartment/tenant'
5
- require 'apartment/reloader'
6
5
 
7
6
  module Apartment
8
7
  class Railtie < Rails::Railtie
@@ -32,7 +31,7 @@ module Apartment
32
31
  #
33
32
  config.to_prepare do
34
33
  next if ARGV.any? { |arg| arg =~ /\Aassets:(?:precompile|clean)\z/ }
35
- next if ARGV.any? { |arg| arg == 'webpacker:compile' }
34
+ next if ARGV.any?('webpacker:compile')
36
35
  next if ENV['APARTMENT_DISABLE_INIT']
37
36
 
38
37
  begin
@@ -60,25 +59,5 @@ module Apartment
60
59
  load 'tasks/apartment.rake'
61
60
  require 'apartment/tasks/enhancements' if Apartment.db_migrate_tenants
62
61
  end
63
-
64
- #
65
- # The following initializers are a workaround to the fact that I can't properly hook into the rails reloader
66
- # Note this is technically valid for any environment where cache_classes is false, for us, it's just development
67
- #
68
- if Rails.env.development?
69
-
70
- # Apartment::Reloader is middleware to initialize things properly on each request to dev
71
- initializer 'apartment.init' do |app|
72
- app.config.middleware.use Apartment::Reloader
73
- end
74
-
75
- # Overrides reload! to also call Apartment::Tenant.init as well
76
- # so that the reloaded classes have the proper table_names
77
- # rubocop:disable Lint/Debugger
78
- console do
79
- require 'apartment/console'
80
- end
81
- # rubocop:enable Lint/Debugger
82
- end
83
62
  end
84
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Apartment
4
- VERSION = '2.9.0'
4
+ VERSION = '2.11.0'
5
5
  end
data/lib/apartment.rb CHANGED
@@ -107,13 +107,13 @@ module Apartment
107
107
  def database_schema_file
108
108
  return @database_schema_file if defined?(@database_schema_file)
109
109
 
110
- @database_schema_file = Rails.root.join('db', 'schema.rb')
110
+ @database_schema_file = Rails.root.join('db/schema.rb')
111
111
  end
112
112
 
113
113
  def seed_data_file
114
114
  return @seed_data_file if defined?(@seed_data_file)
115
115
 
116
- @seed_data_file = Rails.root.join('db', 'seeds.rb')
116
+ @seed_data_file = Rails.root.join('db/seeds.rb')
117
117
  end
118
118
 
119
119
  def pg_excluded_names
@@ -17,12 +17,10 @@ apartment_namespace = namespace :apartment do
17
17
  desc 'Drop all tenants'
18
18
  task :drop do
19
19
  Apartment::TaskHelper.tenants.each do |tenant|
20
- begin
21
- puts("Dropping #{tenant} tenant")
22
- Apartment::Tenant.drop(tenant)
23
- rescue Apartment::TenantNotFound, ActiveRecord::NoDatabaseError => e
24
- puts e.message
25
- end
20
+ puts("Dropping #{tenant} tenant")
21
+ Apartment::Tenant.drop(tenant)
22
+ rescue Apartment::TenantNotFound, ActiveRecord::NoDatabaseError => e
23
+ puts e.message
26
24
  end
27
25
  end
28
26
 
@@ -39,15 +37,13 @@ apartment_namespace = namespace :apartment do
39
37
  Apartment::TaskHelper.warn_if_tenants_empty
40
38
 
41
39
  Apartment::TaskHelper.each_tenant do |tenant|
42
- begin
43
- Apartment::TaskHelper.create_tenant(tenant)
44
- puts("Seeding #{tenant} tenant")
45
- Apartment::Tenant.switch(tenant) do
46
- Apartment::Tenant.seed
47
- end
48
- rescue Apartment::TenantNotFound => e
49
- puts e.message
40
+ Apartment::TaskHelper.create_tenant(tenant)
41
+ puts("Seeding #{tenant} tenant")
42
+ Apartment::Tenant.switch(tenant) do
43
+ Apartment::Tenant.seed
50
44
  end
45
+ rescue Apartment::TenantNotFound => e
46
+ puts e.message
51
47
  end
52
48
  end
53
49
 
@@ -58,12 +54,10 @@ apartment_namespace = namespace :apartment do
58
54
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
59
55
 
60
56
  Apartment::TaskHelper.each_tenant do |tenant|
61
- begin
62
- puts("Rolling back #{tenant} tenant")
63
- Apartment::Migrator.rollback tenant, step
64
- rescue Apartment::TenantNotFound => e
65
- puts e.message
66
- end
57
+ puts("Rolling back #{tenant} tenant")
58
+ Apartment::Migrator.rollback tenant, step
59
+ rescue Apartment::TenantNotFound => e
60
+ puts e.message
67
61
  end
68
62
  end
69
63
 
@@ -76,12 +70,10 @@ apartment_namespace = namespace :apartment do
76
70
  raise 'VERSION is required' unless version
77
71
 
78
72
  Apartment::TaskHelper.each_tenant do |tenant|
79
- begin
80
- puts("Migrating #{tenant} tenant up")
81
- Apartment::Migrator.run :up, tenant, version
82
- rescue Apartment::TenantNotFound => e
83
- puts e.message
84
- end
73
+ puts("Migrating #{tenant} tenant up")
74
+ Apartment::Migrator.run :up, tenant, version
75
+ rescue Apartment::TenantNotFound => e
76
+ puts e.message
85
77
  end
86
78
  end
87
79
 
@@ -93,12 +85,10 @@ apartment_namespace = namespace :apartment do
93
85
  raise 'VERSION is required' unless version
94
86
 
95
87
  Apartment::TaskHelper.each_tenant do |tenant|
96
- begin
97
- puts("Migrating #{tenant} tenant down")
98
- Apartment::Migrator.run :down, tenant, version
99
- rescue Apartment::TenantNotFound => e
100
- puts e.message
101
- end
88
+ puts("Migrating #{tenant} tenant down")
89
+ Apartment::Migrator.run :down, tenant, version
90
+ rescue Apartment::TenantNotFound => e
91
+ puts e.message
102
92
  end
103
93
  end
104
94
 
@@ -27,17 +27,23 @@ Gem::Specification.new do |s|
27
27
  s.homepage = 'https://github.com/rails-on-services/apartment'
28
28
  s.licenses = ['MIT']
29
29
 
30
- s.add_dependency 'activerecord', '>= 5.0.0', '< 6.2'
31
- s.add_dependency 'parallel', '< 2.0'
32
- s.add_dependency 'public_suffix', '>= 2.0.5', '< 5.0'
33
- s.add_dependency 'rack', '>= 1.3.6', '< 3.0'
30
+ s.add_dependency 'activerecord', '>= 5.0.0', '< 7.1'
31
+ s.add_dependency 'parallel', '< 2.0'
32
+ s.add_dependency 'public_suffix', '>= 2.0.5', '< 5.0'
33
+ s.add_dependency 'rack', '>= 1.3.6', '< 3.0'
34
34
 
35
- s.add_development_dependency 'appraisal', '~> 2.2'
36
- s.add_development_dependency 'bundler', '>= 1.3', '< 3.0'
37
- s.add_development_dependency 'capybara', '~> 2.0'
38
- s.add_development_dependency 'rake', '~> 13.0'
39
- s.add_development_dependency 'rspec', '~> 3.4'
40
- s.add_development_dependency 'rspec-rails', '~> 3.4'
35
+ s.add_development_dependency 'appraisal', '~> 2.2'
36
+ s.add_development_dependency 'bundler', '>= 1.3', '< 3.0'
37
+ s.add_development_dependency 'guard-rspec', '~> 4.2'
38
+ s.add_development_dependency 'pry'
39
+ s.add_development_dependency 'rake', '~> 13.0'
40
+ s.add_development_dependency 'rspec', '~> 3.4'
41
+ s.add_development_dependency 'rspec_junit_formatter'
42
+ s.add_development_dependency 'rspec-rails', '~> 3.4'
43
+ s.add_development_dependency 'rubocop', '~> 0.93'
44
+ s.add_development_dependency 'rubocop-performance', '~> 1.10'
45
+ s.add_development_dependency 'rubocop-rails', '~> 2.1'
46
+ s.add_development_dependency 'rubocop-rspec', '~> 1.44'
41
47
 
42
48
  if defined?(JRUBY_VERSION)
43
49
  s.add_development_dependency 'activerecord-jdbc-adapter'
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ros-apartment
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
8
8
  - Brad Robertson
9
9
  - Rui Baltazar
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-21 00:00:00.000000000 Z
13
+ date: 2022-02-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 5.0.0
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '6.2'
24
+ version: '7.1'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,7 +31,7 @@ dependencies:
31
31
  version: 5.0.0
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '6.2'
34
+ version: '7.1'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: parallel
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -121,19 +121,33 @@ dependencies:
121
121
  - !ruby/object:Gem::Version
122
122
  version: '3.0'
123
123
  - !ruby/object:Gem::Dependency
124
- name: capybara
124
+ name: guard-rspec
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '2.0'
129
+ version: '4.2'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '2.0'
136
+ version: '4.2'
137
+ - !ruby/object:Gem::Dependency
138
+ name: pry
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
137
151
  - !ruby/object:Gem::Dependency
138
152
  name: rake
139
153
  requirement: !ruby/object:Gem::Requirement
@@ -162,6 +176,20 @@ dependencies:
162
176
  - - "~>"
163
177
  - !ruby/object:Gem::Version
164
178
  version: '3.4'
179
+ - !ruby/object:Gem::Dependency
180
+ name: rspec_junit_formatter
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
165
193
  - !ruby/object:Gem::Dependency
166
194
  name: rspec-rails
167
195
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +204,62 @@ dependencies:
176
204
  - - "~>"
177
205
  - !ruby/object:Gem::Version
178
206
  version: '3.4'
207
+ - !ruby/object:Gem::Dependency
208
+ name: rubocop
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: '0.93'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - "~>"
219
+ - !ruby/object:Gem::Version
220
+ version: '0.93'
221
+ - !ruby/object:Gem::Dependency
222
+ name: rubocop-performance
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "~>"
226
+ - !ruby/object:Gem::Version
227
+ version: '1.10'
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "~>"
233
+ - !ruby/object:Gem::Version
234
+ version: '1.10'
235
+ - !ruby/object:Gem::Dependency
236
+ name: rubocop-rails
237
+ requirement: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: '2.1'
242
+ type: :development
243
+ prerelease: false
244
+ version_requirements: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - "~>"
247
+ - !ruby/object:Gem::Version
248
+ version: '2.1'
249
+ - !ruby/object:Gem::Dependency
250
+ name: rubocop-rspec
251
+ requirement: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - "~>"
254
+ - !ruby/object:Gem::Version
255
+ version: '1.44'
256
+ type: :development
257
+ prerelease: false
258
+ version_requirements: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - "~>"
261
+ - !ruby/object:Gem::Version
262
+ version: '1.44'
179
263
  - !ruby/object:Gem::Dependency
180
264
  name: mysql2
181
265
  requirement: !ruby/object:Gem::Requirement
@@ -231,11 +315,13 @@ files:
231
315
  - ".circleci/config.yml"
232
316
  - ".github/ISSUE_TEMPLATE.md"
233
317
  - ".github/workflows/changelog.yml"
318
+ - ".github/workflows/reviewdog.yml"
234
319
  - ".gitignore"
235
320
  - ".pryrc"
236
321
  - ".rspec"
237
322
  - ".rubocop.yml"
238
323
  - ".rubocop_todo.yml"
324
+ - ".ruby-version"
239
325
  - ".story_branch.yml"
240
326
  - Appraisals
241
327
  - CHANGELOG.md
@@ -246,16 +332,15 @@ files:
246
332
  - Rakefile
247
333
  - TODO.md
248
334
  - docker-compose.yml
249
- - gemfiles/rails_4_2.gemfile
250
- - gemfiles/rails_5_0.gemfile
251
- - gemfiles/rails_5_1.gemfile
252
335
  - gemfiles/rails_5_2.gemfile
253
336
  - gemfiles/rails_6_0.gemfile
254
337
  - gemfiles/rails_6_1.gemfile
338
+ - gemfiles/rails_7_0.gemfile
255
339
  - gemfiles/rails_master.gemfile
256
340
  - lib/apartment.rb
257
341
  - lib/apartment/active_record/connection_handling.rb
258
342
  - lib/apartment/active_record/internal_metadata.rb
343
+ - lib/apartment/active_record/postgresql_adapter.rb
259
344
  - lib/apartment/active_record/schema_migration.rb
260
345
  - lib/apartment/adapters/abstract_adapter.rb
261
346
  - lib/apartment/adapters/abstract_jdbc_adapter.rb
@@ -278,7 +363,6 @@ files:
278
363
  - lib/apartment/migrator.rb
279
364
  - lib/apartment/model.rb
280
365
  - lib/apartment/railtie.rb
281
- - lib/apartment/reloader.rb
282
366
  - lib/apartment/tasks/enhancements.rb
283
367
  - lib/apartment/tasks/task_helper.rb
284
368
  - lib/apartment/tenant.rb
@@ -292,7 +376,7 @@ homepage: https://github.com/rails-on-services/apartment
292
376
  licenses:
293
377
  - MIT
294
378
  metadata: {}
295
- post_install_message:
379
+ post_install_message:
296
380
  rdoc_options: []
297
381
  require_paths:
298
382
  - lib
@@ -307,8 +391,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
391
  - !ruby/object:Gem::Version
308
392
  version: '0'
309
393
  requirements: []
310
- rubygems_version: 3.1.4
311
- signing_key:
394
+ rubygems_version: 3.1.6
395
+ signing_key:
312
396
  specification_version: 4
313
397
  summary: A Ruby gem for managing database multitenancy. Apartment Gem drop in replacement
314
398
  test_files: []
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'http://rubygems.org'
6
-
7
- gem 'rails', '~> 4.2.0'
8
-
9
- group :local do
10
- gem 'guard-rspec', '~> 4.2'
11
- gem 'pry'
12
- end
13
-
14
- platforms :ruby do
15
- gem 'mysql2', '~> 0.4.0'
16
- gem 'pg', '< 1.0.0'
17
- end
18
-
19
- platforms :jruby do
20
- gem 'activerecord-jdbc-adapter', '~> 1.3'
21
- gem 'activerecord-jdbcmysql-adapter', '~> 1.3'
22
- gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3'
23
- end
24
-
25
- gemspec path: '../'
@@ -1,23 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0"
6
- gem "rubocop"
7
-
8
- group :local do
9
- gem "guard-rspec", "~> 4.2"
10
- gem "pry"
11
- end
12
-
13
- platforms :ruby do
14
- gem "pg", "< 1.0.0"
15
- end
16
-
17
- platforms :jruby do
18
- gem "activerecord-jdbc-adapter", "~> 50.0"
19
- gem "activerecord-jdbcpostgresql-adapter", "~> 50.0"
20
- gem "activerecord-jdbcmysql-adapter", "~> 50.0"
21
- end
22
-
23
- gemspec path: "../"
@@ -1,23 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
- gem "rubocop"
7
-
8
- group :local do
9
- gem "guard-rspec", "~> 4.2"
10
- gem "pry"
11
- end
12
-
13
- platforms :ruby do
14
- gem "pg", "< 1.0.0"
15
- end
16
-
17
- platforms :jruby do
18
- gem "activerecord-jdbc-adapter", "~> 51.0"
19
- gem "activerecord-jdbcpostgresql-adapter", "~> 51.0"
20
- gem "activerecord-jdbcmysql-adapter", "~> 51.0"
21
- end
22
-
23
- gemspec path: "../"
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Apartment
4
- class Reloader
5
- # Middleware used in development to init Apartment for each request
6
- # Necessary due to code reload (annoying). When models are reloaded, they no longer have the proper table_name
7
- # That is prepended with the schema (if using postgresql schemas)
8
- # I couldn't figure out how to properly hook into the Rails reload process *after* files are reloaded
9
- # so I've used this in the meantime.
10
- #
11
- # Also see apartment/console for the re-definition of reload! that re-init's Apartment
12
- #
13
- def initialize(app)
14
- @app = app
15
- end
16
-
17
- def call(env)
18
- Tenant.init
19
- @app.call(env)
20
- end
21
- end
22
- end