ros-apartment 2.3.0.alpha1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.pryrc +5 -3
  3. data/.rubocop.yml +36 -0
  4. data/.rubocop_todo.yml +439 -0
  5. data/.ruby-version +1 -0
  6. data/Appraisals +31 -52
  7. data/CHANGELOG.md +965 -0
  8. data/Gemfile +2 -7
  9. data/Guardfile +3 -16
  10. data/README.md +121 -44
  11. data/Rakefile +42 -31
  12. data/lib/apartment/active_record/connection_handling.rb +31 -0
  13. data/lib/apartment/active_record/internal_metadata.rb +9 -0
  14. data/lib/apartment/active_record/postgresql_adapter.rb +43 -0
  15. data/lib/apartment/active_record/schema_migration.rb +11 -0
  16. data/lib/apartment/adapters/abstract_adapter.rb +52 -46
  17. data/lib/apartment/adapters/abstract_jdbc_adapter.rb +5 -3
  18. data/lib/apartment/adapters/jdbc_mysql_adapter.rb +3 -3
  19. data/lib/apartment/adapters/jdbc_postgresql_adapter.rb +19 -13
  20. data/lib/apartment/adapters/mysql2_adapter.rb +15 -9
  21. data/lib/apartment/adapters/postgis_adapter.rb +3 -2
  22. data/lib/apartment/adapters/postgresql_adapter.rb +79 -31
  23. data/lib/apartment/adapters/sqlite3_adapter.rb +18 -8
  24. data/lib/apartment/adapters/trilogy_adapter.rb +29 -0
  25. data/lib/apartment/console.rb +23 -11
  26. data/lib/apartment/custom_console.rb +42 -0
  27. data/lib/apartment/deprecation.rb +2 -1
  28. data/lib/apartment/elevators/domain.rb +4 -3
  29. data/lib/apartment/elevators/first_subdomain.rb +3 -2
  30. data/lib/apartment/elevators/generic.rb +4 -3
  31. data/lib/apartment/elevators/host.rb +6 -1
  32. data/lib/apartment/elevators/host_hash.rb +6 -2
  33. data/lib/apartment/elevators/subdomain.rb +9 -5
  34. data/lib/apartment/log_subscriber.rb +45 -0
  35. data/lib/apartment/migrator.rb +7 -24
  36. data/lib/apartment/model.rb +29 -0
  37. data/lib/apartment/railtie.rb +21 -20
  38. data/lib/apartment/tasks/enhancements.rb +4 -6
  39. data/lib/apartment/tasks/task_helper.rb +52 -0
  40. data/lib/apartment/tenant.rb +7 -10
  41. data/lib/apartment/version.rb +3 -1
  42. data/lib/apartment.rb +46 -15
  43. data/lib/generators/apartment/install/install_generator.rb +4 -3
  44. data/lib/generators/apartment/install/templates/apartment.rb +10 -3
  45. data/lib/tasks/apartment.rake +48 -87
  46. data/ros-apartment.gemspec +65 -0
  47. metadata +181 -264
  48. data/.github/ISSUE_TEMPLATE.md +0 -21
  49. data/.travis.yml +0 -65
  50. data/HISTORY.md +0 -398
  51. data/TODO.md +0 -51
  52. data/apartment.gemspec +0 -46
  53. data/docker-compose.yml +0 -33
  54. data/gemfiles/rails_4_2.gemfile +0 -23
  55. data/gemfiles/rails_5_0.gemfile +0 -22
  56. data/gemfiles/rails_5_1.gemfile +0 -22
  57. data/gemfiles/rails_5_2.gemfile +0 -18
  58. data/gemfiles/rails_6_0.gemfile +0 -22
  59. data/gemfiles/rails_master.gemfile +0 -22
  60. data/lib/apartment/reloader.rb +0 -21
  61. data/spec/adapters/jdbc_mysql_adapter_spec.rb +0 -19
  62. data/spec/adapters/jdbc_postgresql_adapter_spec.rb +0 -41
  63. data/spec/adapters/mysql2_adapter_spec.rb +0 -59
  64. data/spec/adapters/postgresql_adapter_spec.rb +0 -61
  65. data/spec/adapters/sqlite3_adapter_spec.rb +0 -83
  66. data/spec/apartment_spec.rb +0 -11
  67. data/spec/config/database.yml.sample +0 -49
  68. data/spec/dummy/Rakefile +0 -7
  69. data/spec/dummy/app/controllers/application_controller.rb +0 -6
  70. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  71. data/spec/dummy/app/models/company.rb +0 -3
  72. data/spec/dummy/app/models/user.rb +0 -3
  73. data/spec/dummy/app/views/application/index.html.erb +0 -1
  74. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  75. data/spec/dummy/config/application.rb +0 -49
  76. data/spec/dummy/config/boot.rb +0 -11
  77. data/spec/dummy/config/database.yml.sample +0 -44
  78. data/spec/dummy/config/environment.rb +0 -5
  79. data/spec/dummy/config/environments/development.rb +0 -28
  80. data/spec/dummy/config/environments/production.rb +0 -51
  81. data/spec/dummy/config/environments/test.rb +0 -34
  82. data/spec/dummy/config/initializers/apartment.rb +0 -4
  83. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  84. data/spec/dummy/config/initializers/inflections.rb +0 -10
  85. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  86. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  87. data/spec/dummy/config/initializers/session_store.rb +0 -8
  88. data/spec/dummy/config/locales/en.yml +0 -5
  89. data/spec/dummy/config/routes.rb +0 -3
  90. data/spec/dummy/config.ru +0 -4
  91. data/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb +0 -39
  92. data/spec/dummy/db/migrate/20111202022214_create_table_books.rb +0 -14
  93. data/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb +0 -13
  94. data/spec/dummy/db/schema.rb +0 -55
  95. data/spec/dummy/db/seeds/import.rb +0 -5
  96. data/spec/dummy/db/seeds.rb +0 -5
  97. data/spec/dummy/db/test.sqlite3 +0 -0
  98. data/spec/dummy/public/404.html +0 -26
  99. data/spec/dummy/public/422.html +0 -26
  100. data/spec/dummy/public/500.html +0 -26
  101. data/spec/dummy/public/favicon.ico +0 -0
  102. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  103. data/spec/dummy/script/rails +0 -6
  104. data/spec/dummy_engine/.gitignore +0 -8
  105. data/spec/dummy_engine/Gemfile +0 -15
  106. data/spec/dummy_engine/Rakefile +0 -34
  107. data/spec/dummy_engine/bin/rails +0 -12
  108. data/spec/dummy_engine/config/initializers/apartment.rb +0 -51
  109. data/spec/dummy_engine/dummy_engine.gemspec +0 -24
  110. data/spec/dummy_engine/lib/dummy_engine/engine.rb +0 -4
  111. data/spec/dummy_engine/lib/dummy_engine/version.rb +0 -3
  112. data/spec/dummy_engine/lib/dummy_engine.rb +0 -4
  113. data/spec/dummy_engine/test/dummy/Rakefile +0 -6
  114. data/spec/dummy_engine/test/dummy/config/application.rb +0 -22
  115. data/spec/dummy_engine/test/dummy/config/boot.rb +0 -5
  116. data/spec/dummy_engine/test/dummy/config/database.yml +0 -25
  117. data/spec/dummy_engine/test/dummy/config/environment.rb +0 -5
  118. data/spec/dummy_engine/test/dummy/config/environments/development.rb +0 -37
  119. data/spec/dummy_engine/test/dummy/config/environments/production.rb +0 -78
  120. data/spec/dummy_engine/test/dummy/config/environments/test.rb +0 -39
  121. data/spec/dummy_engine/test/dummy/config/initializers/assets.rb +0 -8
  122. data/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  123. data/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  124. data/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  125. data/spec/dummy_engine/test/dummy/config/initializers/inflections.rb +0 -16
  126. data/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb +0 -4
  127. data/spec/dummy_engine/test/dummy/config/initializers/session_store.rb +0 -3
  128. data/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  129. data/spec/dummy_engine/test/dummy/config/locales/en.yml +0 -23
  130. data/spec/dummy_engine/test/dummy/config/routes.rb +0 -56
  131. data/spec/dummy_engine/test/dummy/config/secrets.yml +0 -22
  132. data/spec/dummy_engine/test/dummy/config.ru +0 -4
  133. data/spec/examples/connection_adapter_examples.rb +0 -42
  134. data/spec/examples/generic_adapter_custom_configuration_example.rb +0 -95
  135. data/spec/examples/generic_adapter_examples.rb +0 -163
  136. data/spec/examples/schema_adapter_examples.rb +0 -234
  137. data/spec/integration/apartment_rake_integration_spec.rb +0 -107
  138. data/spec/integration/query_caching_spec.rb +0 -81
  139. data/spec/integration/use_within_an_engine_spec.rb +0 -28
  140. data/spec/schemas/v1.rb +0 -16
  141. data/spec/schemas/v2.rb +0 -43
  142. data/spec/schemas/v3.rb +0 -49
  143. data/spec/spec_helper.rb +0 -61
  144. data/spec/support/apartment_helpers.rb +0 -43
  145. data/spec/support/capybara_sessions.rb +0 -15
  146. data/spec/support/config.rb +0 -10
  147. data/spec/support/contexts.rb +0 -52
  148. data/spec/support/requirements.rb +0 -35
  149. data/spec/support/setup.rb +0 -46
  150. data/spec/tasks/apartment_rake_spec.rb +0 -129
  151. data/spec/tenant_spec.rb +0 -190
  152. data/spec/unit/config_spec.rb +0 -112
  153. data/spec/unit/elevators/domain_spec.rb +0 -32
  154. data/spec/unit/elevators/first_subdomain_spec.rb +0 -24
  155. data/spec/unit/elevators/generic_spec.rb +0 -54
  156. data/spec/unit/elevators/host_hash_spec.rb +0 -32
  157. data/spec/unit/elevators/host_spec.rb +0 -89
  158. data/spec/unit/elevators/subdomain_spec.rb +0 -76
  159. data/spec/unit/migrator_spec.rb +0 -77
  160. data/spec/unit/reloader_spec.rb +0 -24
data/.travis.yml DELETED
@@ -1,65 +0,0 @@
1
- os: linux
2
-
3
- language: ruby
4
- services:
5
- - docker
6
- rvm:
7
- - jruby-9.1.17.0
8
- - 2.1.9
9
- - 2.2.9
10
- - 2.3.6
11
- - 2.4.3
12
- - 2.5.0
13
- - 2.6.2
14
- - ruby-head
15
- gemfile:
16
- - gemfiles/rails_4_2.gemfile
17
- - gemfiles/rails_5_0.gemfile
18
- - gemfiles/rails_5_1.gemfile
19
- - gemfiles/rails_5_2.gemfile
20
- - gemfiles/rails_6_0.gemfile
21
- - gemfiles/rails_master.gemfile
22
- bundler_args: --without local
23
- before_install:
24
- - sudo /etc/init.d/mysql stop
25
- - sudo /etc/init.d/postgresql stop
26
- - docker-compose up -d
27
- - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
28
- - gem uninstall bundler -v '>= 2' -x || true
29
- - gem install bundler -v '< 2'
30
- env:
31
- RUBY_GC_MALLOC_LIMIT: 90000000
32
- RUBY_GC_HEAP_FREE_SLOTS: 200000
33
- jobs:
34
- allow_failures:
35
- - rvm: ruby-head
36
- - gemfile: gemfiles/rails_master.gemfile
37
- - rvm: jruby-9.1.17.0
38
- gemfile: gemfiles/rails_5_0.gemfile
39
- exclude:
40
- - rvm: 2.1.9
41
- gemfile: gemfiles/rails_5_0.gemfile
42
- - rvm: 2.1.9
43
- gemfile: gemfiles/rails_5_1.gemfile
44
- - rvm: 2.1.9
45
- gemfile: gemfiles/rails_5_2.gemfile
46
- - rvm: 2.1.9
47
- gemfile: gemfiles/rails_6_0.gemfile
48
- - rvm: 2.1.9
49
- gemfile: gemfiles/rails_master.gemfile
50
- - rvm: 2.2.9
51
- gemfile: gemfiles/rails_6_0.gemfile
52
- - rvm: 2.3.6
53
- gemfile: gemfiles/rails_6_0.gemfile
54
- - rvm: 2.4.3
55
- gemfile: gemfiles/rails_6_0.gemfile
56
- - rvm: jruby-9.1.17.0
57
- gemfile: gemfiles/rails_5_1.gemfile
58
- - rvm: jruby-9.1.17.0
59
- gemfile: gemfiles/rails_5_2.gemfile
60
- - rvm: jruby-9.1.17.0
61
- gemfile: gemfiles/rails_6_0.gemfile
62
- - rvm: jruby-9.1.17.0
63
- gemfile: gemfiles/rails_master.gemfile
64
- fast_finish: true
65
- cache: bundler
data/HISTORY.md DELETED
@@ -1,398 +0,0 @@
1
- # 2.2.1
2
- * June 19, 2019
3
-
4
- ## Added
5
- - #566: IGNORE_EMPTY_TENANTS environment variable to ignore empty tenants
6
- warning. [Pysis868]
7
-
8
- ## Fixed
9
- - #586: Ignore `CREATE SCHEMA public` statement in pg dump [artemave]
10
- - #549: Fix Postgres schema creation with dump SQL [ancorcruz]
11
-
12
- # 2.2.0
13
- * April 14, 2018
14
-
15
- ## Added
16
- - #523: Add Rails 5.2 support [IngusSkaistkalns]
17
- - #504: Test against Ruby 2.5.0 [ahorek]
18
- - #528: Test against Rails 5.2 [meganemura]
19
-
20
- ## Removed
21
- - #504: Remove Rails 4.0/4.1 support [ahorek]
22
- - #545: Stop supporting for JRuby + Rails 5.0 [meganemura]
23
-
24
- ## Fixed
25
- - #537: Fix PostgresqlSchemaFromSqlAdapter for newer PostgreSQL [shterrett]
26
- - #532: Issue is reported by [aldrinmartoq]
27
- - #519: Fix exception when main database doesn't exist [mayeco]
28
-
29
- ## Changed
30
- - #514: Fix typo [menorval]
31
-
32
- # 2.1.0
33
- * December 15, 2017
34
-
35
- - Add `parallel_migration_threads` configuration option for running migrations
36
- in parallel [ryanbrunner]
37
- - Drop Ruby 2.0.0 support [meganemura]
38
- - ignore_private when parsing subdomains with PublicSuffix [michiomochi]
39
- - Ignore row_security statements in psql dumps for backward compatibility
40
- [meganemura]
41
- - "Host" elevator [shrmnk]
42
- - Enhance db:drop task to act on all tenants [kuzukuzu]
43
-
44
- # 2.0.0
45
- * July 26, 2017
46
-
47
- - Raise FileNotFound rather than abort when loading files [meganemura]
48
- - Add 5.1 support with fixes for deprecations [meganemura]
49
- - Fix tests for 5.x and a host of dev-friendly improvements [meganemura]
50
- - Keep query cache config after switching databases [fernandomm]
51
- - Pass constants not strings to middleware stack (Rails 5) [tzabaman]
52
- - Remove deprecations from 1.0.0 [caironoleto]
53
- - Replace `tld_length` configuration option with PublicSuffix gem for the
54
- subdomain elevator [humancopy]
55
- - Pass full config to create_database to allow :encoding/:collation/etc
56
- [kakipo]
57
- - Don't retain a connection during initialization [mikecmpbll]
58
- - Fix database name escaping in drop_command [mikecmpbll]
59
- - Skip initialization for assets:clean and assets:precompile tasks
60
- [frank-west-iii]
61
-
62
- # 1.2.0
63
- * July 28, 2016
64
-
65
- - Official Rails 5 support
66
-
67
- # 1.1.0
68
- * May 26, 2016
69
-
70
- - Reset tenant after each request
71
- - [Support callbacks](https://github.com/influitive/apartment/commit/ff9c9d092a781026502f5997c0bbedcb5748bc83) on switch [cbeer]
72
- - Preliminary support for [separate database hosts](https://github.com/influitive/apartment/commit/abdffbf8cd9fba87243f16c86390da13e318ee1f) [apneadiving]
73
-
74
- # 1.0.2
75
- * July 2, 2015
76
-
77
- - Fix pg_dump env vars - pull/208 [MitinPavel]
78
- - Allow custom seed data file - pull/234 [typeoneerror]
79
-
80
- # 1.0.1
81
- * April 28, 2015
82
-
83
- - Fix `Apartment::Deprecation` which was rescuing all exceptions
84
-
85
- # 1.0.0
86
- * Feb 3, 2015
87
-
88
- - [BREAKING CHANGE] `Apartment::Tenant.process` is deprecated in favour of `Apartment::Tenant.switch`
89
- - [BREAKING CHANGE] `Apartment::Tenant.switch` without a block is deprecated in favour of `Apartment::Tenant.switch!`
90
- - Raise proper `TenantNotFound`, `TenantExists` exceptions
91
- - Deprecate old `SchemaNotFound`, `DatabaseNotFound` exceptions
92
-
93
- # 0.26.1
94
- * Jan 13, 2015
95
-
96
- - Fixed [schema quoting bug](https://github.com/influitive/apartment/issues/198#issuecomment-69782651) [jonsgreen]
97
-
98
- # 0.26.0
99
- * Jan 5, 2015
100
-
101
- - Rails 4.2 support
102
-
103
- # 0.25.2
104
- * Sept 8, 2014
105
-
106
- - Heroku fix on `assets:precompile` - pull/169 [rabbitt]
107
-
108
- # 0.25.1
109
- * July 17, 2014
110
-
111
- - Fixed a few vestiges of Apartment::Database
112
-
113
- # 0.25.0
114
- * July 3, 2014
115
-
116
- - [BREAKING CHANGE] - `Apartment::Database` is not deprecated in favour of
117
- `Apartment::Tenant`
118
- - ActiveRecord (and Rails) 4.1 now supported
119
- - A new sql based adapter that dumps the schema using sql
120
-
121
- # 0.24.3
122
- * March 5, 2014
123
-
124
- - Rake enhancements weren't removed from the generator template
125
-
126
- # 0.24.2
127
- * February 24, 2014
128
-
129
- - Better warnings if `apartment:migrate` is run
130
-
131
- # 0.24.1
132
- * February 21, 2014
133
-
134
- - requiring `apartment/tasks/enhancements` in an initializer doesn't work
135
- - One can disable tenant migrations using `Apartment.db_migrate_tenants = false` in the Rakefile
136
-
137
- # 0.24
138
- * February 21, 2014 (In honour of the Women's Gold Medal in Hockey at Sochi)
139
-
140
- - [BREAKING CHANGE] `apartment:migrate` task no longer depends on `db:migrate`
141
- - Instead, you can `require 'apartment/tasks/enhancements'` in your Apartment initializer
142
- - This will enhance `rake db:migrate` to also run `apartment:migrate`
143
- - You can now forget about ever running `apartment:migrate` again
144
- - Numerous deprecations for things referencing the word 'database'
145
- - This is an ongoing effort to completely replace 'database' with 'tenant' as a better abstraction
146
- - Note the obvious `Apartment::Database` still exists but will hopefully become `Apartment::Tenant` soon
147
-
148
- # 0.23.2
149
- * January 9, 2014
150
-
151
- - Increased visibility of #parse_database_name warning
152
-
153
- # 0.23.1
154
- * January 8, 2014
155
-
156
- - Schema adapters now initialize with default and persistent schemas
157
- - Deprecated Apartment::Elevators#parse_database_name
158
-
159
- # 0.23.0
160
- * August 21, 2013
161
-
162
- - Subdomain Elevator now allows for exclusions
163
- - Delayed::Job has been completely removed
164
-
165
- # 0.22.1
166
- * August 21, 2013
167
-
168
- - Fix bug where if your ruby process importing the database schema is run
169
- from a directory other than the app root, Apartment wouldn't know what
170
- schema_migrations to insert into the database (Rails only)
171
-
172
- # 0.22.0
173
- * June 9, 2013
174
-
175
- - Numerous bug fixes:
176
- - Mysql reset could connect to wrong database [eric88]
177
- - Postgresql schema names weren't quoted properly [gdott9]
178
- - Fixed error message on SchemaNotFound in `process`
179
- - HostHash elevator allows mapping host based on hash contents [gdott9]
180
- - Official Sidekiq support with the [apartment-sidekiq gem](https://github.com/influitive/apartment-sidekiq)
181
-
182
-
183
- # 0.21.1
184
- * May 31, 2013
185
-
186
- - Clearing the AR::QueryCache after switching databases.
187
- - Fixes issue with stale model being loaded for schema adapters
188
-
189
- # 0.21.0
190
- * April 24, 2013
191
-
192
- - JDBC support!! [PetrolMan]
193
-
194
- # 0.20.0
195
- * Feb 6, 2013
196
-
197
- - Mysql now has a 'schema like' option to perform like Postgresql (default)
198
- - This should be significantly more performant than using connections
199
- - Psych is now supported for Delayed::Job yaml parsing
200
-
201
- # 0.19.2
202
- * Jan 30, 2013
203
-
204
- - Database schema file can now be set manually or skipped altogether
205
-
206
- # 0.19.1
207
- * Jan 30, 2013
208
-
209
- - Allow schema.rb import file to be specified in config or skip schema.rb import altogether
210
-
211
- # 0.19.0
212
- * Dec 29, 2012
213
-
214
- - Apartment is now threadsafe
215
- - New postgis adapter [zonpantli]
216
- - Removed ActionDispatch dependency for use with Rack apps (regression)
217
-
218
- # 0.18.0
219
- * Nov 27, 2012
220
-
221
- - Added `append_environment` config option [virtualstaticvoid]
222
- - Cleaned up the readme and generator documentation
223
- - Added `connection_class` config option [smashtank]
224
- - Fixed a [bug](https://github.com/influitive/apartment/issues/17#issuecomment-10758327) in pg adapter when missing schema
225
-
226
- # 0.17.1
227
- * Oct 30, 2012
228
-
229
- - Fixed a bug where switching to an unknown db in mysql2 would crash the app [Frodotus]
230
-
231
- # 0.17.0
232
- * Sept 26, 2012
233
-
234
- - Apartment has [a new home!](https://github.com/influitive/apartment)
235
- - Support Sidekiq hooks to switch dbs [maedhr]
236
- - Allow VERSION to be used on apartment:migrate [Bhavin Kamani]
237
-
238
- # 0.16.0
239
- * June 1, 2012
240
-
241
- - Apartment now supports a default_schema to be set, rather than relying on ActiveRecord's default schema_search_path
242
- - Additional schemas can always be maintained in the schema_search_path by configuring persistent_schemas [ryanbrunner]
243
- - This means Hstore is officially supported!!
244
- - There is now a full domain based elevator to switch dbs based on the whole domain [lcowell]
245
- - There is now a generic elevator that takes a Proc to switch dbs based on the return value of that proc.
246
-
247
- # 0.15.0
248
- * March 18, 2012
249
-
250
- - Remove Rails dependency, Apartment can now be used with any Rack based framework using ActiveRecord
251
-
252
- # 0.14.4
253
- * March 8, 2012
254
-
255
- - Delayed::Job Hooks now return to the previous database, rather than resetting
256
-
257
- # 0.14.3
258
- * Feb 21, 2012
259
-
260
- - Fix yaml serialization of non DJ models
261
-
262
- # 0.14.2
263
- * Feb 21, 2012
264
-
265
- - Fix Delayed::Job yaml encoding with Rails > 3.0.x
266
-
267
- # 0.14.1
268
- * Dec 13, 2011
269
-
270
- - Fix ActionDispatch::Callbacks deprecation warnings
271
-
272
- # 0.14.0
273
- * Dec 13, 2011
274
-
275
- - Rails 3.1 Support
276
-
277
- # 0.13.1
278
- * Nov 8, 2011
279
-
280
- - Reset prepared statement cache for rails 3.1.1 before switching dbs when using postgresql schemas
281
- - Only necessary until the next release which will be more schema aware
282
-
283
- # 0.13.0
284
- * Oct 25, 2011
285
-
286
- - `process` will now rescue with reset if the previous schema/db is no longer available
287
- - `create` now takes an optional block which allows you to process within the newly created db
288
- - Fixed Rails version >= 3.0.10 and < 3.1 because there have been significant testing problems with 3.1, next version will hopefully fix this
289
-
290
- # 0.12.0
291
- * Oct 4, 2011
292
-
293
- - Added a `drop` method for removing databases/schemas
294
- - Refactored abstract adapter to further remove duplication in concrete implementations
295
- - Excluded models now take string references so they are properly reloaded in development
296
- - Better silencing of `schema.rb` loading using `verbose` flag
297
-
298
- # 0.11.1
299
- * Sep 22, 2011
300
-
301
- - Better use of Railties for initializing apartment
302
- - The following changes were necessary as I haven't figured out how to properly hook into Rails reloading
303
- - Added reloader middleware in development to init Apartment on each request
304
- - Override `reload!` in console to also init Apartment
305
-
306
- # 0.11.0
307
- * Sep 20, 2011
308
-
309
- - Excluded models no longer use a different connection when using postgresql schemas. Instead their table_name is prefixed with `public.`
310
-
311
- # 0.10.3
312
- * Sep 20, 2011
313
-
314
- - Fix improper raising of exceptions on create and reset
315
-
316
- # 0.10.2
317
- * Sep 15, 2011
318
-
319
- - Remove all the annoying logging for loading db schema and seeding on create
320
-
321
- # 0.10.1
322
- * Aug 11, 2011
323
-
324
- - Fixed bug in DJ where new objects (that hadn't been pulled from the db) didn't have the proper database assigned
325
-
326
- # 0.10.0
327
- * July 29, 2011
328
-
329
- - Added better support for Delayed Job
330
- - New config option that enables Delayed Job wrappers
331
- - Note that DJ support uses a work-around in order to get queues stored in the public schema, not sure why it doesn't work out of the box, will look into it, until then, see documentation on queue'ng jobs
332
-
333
- # 0.9.2
334
- * July 4, 2011
335
-
336
- - Migrations now run associated rails migration fully, fixes schema.rb not being reloaded after migrations
337
-
338
- # 0.9.1
339
- * June 24, 2011
340
-
341
- - Hooks now take the payload object as an argument to fetch the proper db for DJ hooks
342
-
343
- # 0.9.0
344
- * June 23, 2011
345
-
346
- - Added module to provide delayed job hooks
347
-
348
- # 0.8.0
349
- * June 23, 2011
350
-
351
- - Added #current_database which will return the current database (or schema) name
352
-
353
- # 0.7.0
354
- * June 22, 2011
355
-
356
- - Added apartment:seed rake task for seeding all dbs
357
-
358
- # 0.6.0
359
- * June 21, 2011
360
-
361
- - Added #process to connect to new db, perform operations, then ensure a reset
362
-
363
- # 0.5.1
364
- * June 21, 2011
365
-
366
- - Fixed db migrate up/down/rollback
367
- - added db:redo
368
-
369
- # 0.5.0
370
- * June 20, 2011
371
-
372
- - Added the concept of an "Elevator", a rack based strategy for db switching
373
- - Added the Subdomain Elevator middleware to enabled db switching based on subdomain
374
-
375
- # 0.4.0
376
- * June 14, 2011
377
-
378
- - Added `configure` method on Apartment instead of using yml file, allows for dynamic setting of db names to migrate for rake task
379
- - Added `seed_after_create` config option to import seed data to new db on create
380
-
381
- # 0.3.0
382
- * June 10, 2011
383
-
384
- - Added full support for database migration
385
- - Added in method to establish new connection for excluded models on startup rather than on each switch
386
-
387
- # 0.2.0
388
- * June 6, 2011 *
389
-
390
- - Refactor to use more rails/active_support functionality
391
- - Refactor config to lazily load apartment.yml if exists
392
- - Remove OStruct and just use hashes for fetching methods
393
- - Added schema load on create instead of migrating from scratch
394
-
395
- # 0.1.3
396
- * March 30, 2011 *
397
-
398
- - Original pass from Ryan
data/TODO.md DELETED
@@ -1,51 +0,0 @@
1
- # Apartment TODOs
2
-
3
- ### Below is a list of tasks in the approximate order to be completed of for Apartment
4
- ### Any help along the way is greatly appreciated (on any items, not particularly in order)
5
-
6
- 1. Apartment was originally written (and TDD'd) with just Postgresql in mind. Different adapters were added at a later date.
7
- As such, the test suite is a bit of a mess. There's no formal structure for fully integration testing all adapters to ensure
8
- proper quality and prevent regressions.
9
-
10
- There's also a test order dependency as some tests run assuming a db connection and if that test randomly ran before a previous
11
- one that makes the connection, it would fail.
12
-
13
- I'm proposing the first thing to be done is to write up a standard, high livel integration test case that can be applied to all adapters
14
- and makes no assumptions about implementation. It should ensure that each adapter conforms to the Apartment Interface and CRUD's properly.
15
- It would be nice if a user can 'register' an adapter such that it would automatically be tested (nice to have). Otherwise one could just use
16
- a shared behaviour to run through all of this.
17
-
18
- Then, I'd like to see all of the implementation specific tests just in their own test file for each adapter (ie the postgresql schema adapter checks a lot of things with `schema_search_path`)
19
-
20
- This should ensure that going forward nothing breaks, and we should *ideally* be able to randomize the test order
21
-
22
- 2. <del>`Apartment::Database` is the wrong abstraction. When dealing with a multi-tenanted system, users shouldn't thing about 'Databases', they should
23
- think about Tenants. I proprose that we deprecate the `Apartment::Database` constant in favour of `Apartment::Tenant` for a nicer abstraction. See
24
- http://myronmars.to/n/dev-blog/2011/09/deprecating-constants-and-classes-in-ruby for ideas on how to achieve this.</del>
25
-
26
- 4. Apartment::Database.process should be deprecated in favour of just passing a block to `switch`
27
- 5. Apartment::Database.switch should be renamed to switch! to indicate that using it on its own has side effects
28
-
29
- 6. Migrations right now can be a bit of a pain. Apartment currently migrates a single tenant completely up to date, then goes onto the next. If one of these
30
- migrations fails on a tenant, the previous one does NOT get reverted and leaves you in an awkward state. Ideally we'd want to wrap all of the migrations in
31
- a transaction so if one fails, the whole thing reverts. Once we can ensure an all-or-nothing approach to migrations, we can optimize the migration strategy
32
- to not even iterate over the tenants if there are no migrations to run on public.
33
-
34
- 7. Apartment has be come one of the most popular/robust Multi-tenant gems for Rails, but it still doesn't work for everyone's use case. It's fairly limited in implementation to either schema based (ie postgresql schemas) or connection based. I'd like to abstract out these implementation details such that one could write a pluggable strategy for Apartment and choose it based on a config selection (something like `config.strategy = :schema`). The next implementation I'd like to see is a scoped based approach that uses a `tenant_id` scoping on all records for multi-tenancy. This is probably the most popular multi-tenant approach and is db independent and really the simplest mechanism for a type of multi-tenancy.
35
-
36
- 8. Right now excluded tables still live in all tenanted environments. This is basically because it doesn't matter if they're there, we always query from the public.
37
- It's a bit of an annoyance though and confuses lots of people. I'd love to see only tenanted tables in the tenants and only excluded tables in the public tenant.
38
- This will be hard because Rails uses public to generate schema.rb. One idea is to have an `excluded` schema that holds all the excluded models and the public can
39
- maintain everything.
40
-
41
- 9. This one is pretty lofty, but I'd also like to abstract out the fact that Apartment uses ActiveRecord. With the new DataMapper coming out soon and other popular
42
- DBMS's (ie. mongo, couch etc...), it'd be nice if Apartment could be the de-facto interface for multi-tenancy on these systems.
43
-
44
-
45
- ===================
46
-
47
- Quick TODOs
48
-
49
- 1. `default_tenant` should be up to the adapter, not the Apartment class, deprecate `default_schema`
50
- 2. deprecation.rb rescues everything, we have a hard dependency on ActiveSupport so this is unnecessary
51
- 3.
data/apartment.gemspec DELETED
@@ -1,46 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $: << File.expand_path("../lib", __FILE__)
3
- require "apartment/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = %q{ros-apartment}
7
- s.version = Apartment::VERSION
8
-
9
- s.authors = ["Ryan Brunner", "Brad Robertson"]
10
- s.summary = %q{A Ruby gem for managing database multitenancy}
11
- s.description = %q{Apartment allows Rack applications to deal with database multitenancy through ActiveRecord}
12
- s.email = ["ryan@influitive.com", "brad@influitive.com"]
13
- s.files = `git ls-files`.split($/)
14
- s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
- s.require_paths = ["lib"]
17
-
18
- s.homepage = %q{https://github.com/rails-on-services/apartment}
19
- s.licenses = ["MIT"]
20
-
21
- # must be >= 3.1.2 due to bug in prepared_statements
22
- s.add_dependency 'activerecord', '>= 3.1.2', '< 6.1'
23
- s.add_dependency 'rack', '>= 1.3.6'
24
- s.add_dependency 'public_suffix', '>= 2'
25
- s.add_dependency 'parallel', '>= 0.7.1'
26
-
27
- s.add_development_dependency 'appraisal'
28
- s.add_development_dependency 'rake', '~> 0.9'
29
- s.add_development_dependency 'rspec', '~> 3.4'
30
- s.add_development_dependency 'rspec-rails', '~> 3.4'
31
- s.add_development_dependency 'capybara', '~> 2.0'
32
- s.add_development_dependency 'bundler', '>= 1.3', '< 2.0'
33
-
34
- if defined?(JRUBY_VERSION)
35
- s.add_development_dependency 'activerecord-jdbc-adapter'
36
- s.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
37
- s.add_development_dependency 'activerecord-jdbcmysql-adapter'
38
- s.add_development_dependency 'jdbc-postgres'
39
- s.add_development_dependency 'jdbc-mysql'
40
- s.add_development_dependency 'jruby-openssl'
41
- else
42
- s.add_development_dependency 'mysql2'
43
- s.add_development_dependency 'pg'
44
- s.add_development_dependency 'sqlite3', '~> 1.3.6'
45
- end
46
- end
data/docker-compose.yml DELETED
@@ -1,33 +0,0 @@
1
- version: '2.3'
2
- services:
3
- postgresql:
4
- image: postgres:9.5.12
5
- environment:
6
- POSTGRES_PASSWORD: ""
7
- ports:
8
- - "5432:5432"
9
- healthcheck:
10
- test: pg_isready -U postgres
11
- start_period: 10s
12
- interval: 10s
13
- timeout: 30s
14
- retries: 3
15
- mysql:
16
- image: mysql:5.7
17
- environment:
18
- MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
19
- ports:
20
- - "3306:3306"
21
- healthcheck:
22
- test: mysqladmin -h 127.0.0.1 -uroot ping
23
- start_period: 15s
24
- interval: 10s
25
- timeout: 30s
26
- retries: 3
27
- healthcheck:
28
- image: busybox
29
- depends_on:
30
- postgresql:
31
- condition: service_healthy
32
- mysql:
33
- condition: service_healthy
@@ -1,23 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 4.2.0"
6
-
7
- group :local do
8
- gem "pry"
9
- gem "guard-rspec", "~> 4.2"
10
- end
11
-
12
- platforms :ruby do
13
- gem "pg", "< 1.0.0"
14
- gem "mysql2", "~> 0.4.0"
15
- end
16
-
17
- platforms :jruby do
18
- gem "activerecord-jdbc-adapter", "~> 1.3"
19
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3"
20
- gem "activerecord-jdbcmysql-adapter", "~> 1.3"
21
- end
22
-
23
- gemspec path: "../"
@@ -1,22 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0"
6
-
7
- group :local do
8
- gem "pry"
9
- gem "guard-rspec", "~> 4.2"
10
- end
11
-
12
- platforms :ruby do
13
- gem "pg", "< 1.0.0"
14
- end
15
-
16
- platforms :jruby do
17
- gem "activerecord-jdbc-adapter", "~> 50.0"
18
- gem "activerecord-jdbcpostgresql-adapter", "~> 50.0"
19
- gem "activerecord-jdbcmysql-adapter", "~> 50.0"
20
- end
21
-
22
- gemspec path: "../"
@@ -1,22 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
-
7
- group :local do
8
- gem "pry"
9
- gem "guard-rspec", "~> 4.2"
10
- end
11
-
12
- platforms :ruby do
13
- gem "pg", "< 1.0.0"
14
- end
15
-
16
- platforms :jruby do
17
- gem "activerecord-jdbc-adapter", "~> 51.0"
18
- gem "activerecord-jdbcpostgresql-adapter", "~> 51.0"
19
- gem "activerecord-jdbcmysql-adapter", "~> 51.0"
20
- end
21
-
22
- gemspec path: "../"
@@ -1,18 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.2.0"
6
-
7
- group :local do
8
- gem "pry"
9
- gem "guard-rspec", "~> 4.2"
10
- end
11
-
12
- platforms :jruby do
13
- gem "activerecord-jdbc-adapter", "~> 52.0"
14
- gem "activerecord-jdbcpostgresql-adapter", "~> 52.0"
15
- gem "activerecord-jdbcmysql-adapter", "~> 52.0"
16
- end
17
-
18
- gemspec path: "../"