ros-apartment 2.3.0.alpha2 → 2.6.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/.rubocop-linter.yml +22 -0
- data/.pryrc +5 -3
- data/.rubocop.yml +21 -0
- data/.rubocop_todo.yml +29 -0
- data/.story_branch.yml +4 -0
- data/.travis.yml +15 -36
- data/Appraisals +16 -29
- data/Gemfile +4 -1
- data/Guardfile +3 -1
- data/HISTORY.md +7 -0
- data/README.md +80 -39
- data/Rakefile +45 -23
- data/apartment.gemspec +33 -25
- data/gemfiles/rails_4_2.gemfile +12 -10
- data/gemfiles/rails_5_0.gemfile +2 -1
- data/gemfiles/rails_5_1.gemfile +2 -1
- data/gemfiles/rails_5_2.gemfile +2 -1
- data/gemfiles/rails_6_0.gemfile +6 -5
- data/gemfiles/rails_master.gemfile +2 -1
- data/lib/apartment.rb +36 -11
- data/lib/apartment/active_record/connection_handling.rb +17 -0
- data/lib/apartment/active_record/internal_metadata.rb +11 -0
- data/lib/apartment/active_record/schema_migration.rb +13 -0
- data/lib/apartment/adapters/abstract_adapter.rb +50 -45
- data/lib/apartment/adapters/abstract_jdbc_adapter.rb +4 -3
- data/lib/apartment/adapters/jdbc_mysql_adapter.rb +3 -3
- data/lib/apartment/adapters/jdbc_postgresql_adapter.rb +20 -13
- data/lib/apartment/adapters/mysql2_adapter.rb +10 -9
- data/lib/apartment/adapters/postgis_adapter.rb +3 -2
- data/lib/apartment/adapters/postgresql_adapter.rb +55 -27
- data/lib/apartment/adapters/sqlite3_adapter.rb +18 -8
- data/lib/apartment/console.rb +35 -3
- data/lib/apartment/custom_console.rb +42 -0
- data/lib/apartment/deprecation.rb +2 -1
- data/lib/apartment/elevators/domain.rb +4 -3
- data/lib/apartment/elevators/first_subdomain.rb +3 -2
- data/lib/apartment/elevators/generic.rb +4 -3
- data/lib/apartment/elevators/host.rb +6 -1
- data/lib/apartment/elevators/host_hash.rb +6 -2
- data/lib/apartment/elevators/subdomain.rb +9 -5
- data/lib/apartment/migrator.rb +4 -3
- data/lib/apartment/model.rb +27 -0
- data/lib/apartment/railtie.rb +26 -15
- data/lib/apartment/reloader.rb +2 -1
- data/lib/apartment/tasks/enhancements.rb +4 -6
- data/lib/apartment/tenant.rb +19 -9
- data/lib/apartment/version.rb +3 -1
- data/lib/generators/apartment/install/install_generator.rb +4 -3
- data/lib/generators/apartment/install/templates/apartment.rb +3 -2
- data/lib/tasks/apartment.rake +24 -19
- metadata +79 -256
- data/spec/adapters/jdbc_mysql_adapter_spec.rb +0 -19
- data/spec/adapters/jdbc_postgresql_adapter_spec.rb +0 -41
- data/spec/adapters/mysql2_adapter_spec.rb +0 -59
- data/spec/adapters/postgresql_adapter_spec.rb +0 -61
- data/spec/adapters/sqlite3_adapter_spec.rb +0 -83
- data/spec/apartment_spec.rb +0 -11
- data/spec/config/database.yml.sample +0 -49
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/controllers/application_controller.rb +0 -6
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/company.rb +0 -3
- data/spec/dummy/app/models/user.rb +0 -3
- data/spec/dummy/app/views/application/index.html.erb +0 -1
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -49
- data/spec/dummy/config/boot.rb +0 -11
- data/spec/dummy/config/database.yml.sample +0 -44
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -28
- data/spec/dummy/config/environments/production.rb +0 -51
- data/spec/dummy/config/environments/test.rb +0 -34
- data/spec/dummy/config/initializers/apartment.rb +0 -4
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb +0 -39
- data/spec/dummy/db/migrate/20111202022214_create_table_books.rb +0 -14
- data/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb +0 -13
- data/spec/dummy/db/schema.rb +0 -55
- data/spec/dummy/db/seeds.rb +0 -5
- data/spec/dummy/db/seeds/import.rb +0 -5
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy_engine/.gitignore +0 -8
- data/spec/dummy_engine/Gemfile +0 -15
- data/spec/dummy_engine/Rakefile +0 -34
- data/spec/dummy_engine/bin/rails +0 -12
- data/spec/dummy_engine/config/initializers/apartment.rb +0 -51
- data/spec/dummy_engine/dummy_engine.gemspec +0 -24
- data/spec/dummy_engine/lib/dummy_engine.rb +0 -4
- data/spec/dummy_engine/lib/dummy_engine/engine.rb +0 -4
- data/spec/dummy_engine/lib/dummy_engine/version.rb +0 -3
- data/spec/dummy_engine/test/dummy/Rakefile +0 -6
- data/spec/dummy_engine/test/dummy/config.ru +0 -4
- data/spec/dummy_engine/test/dummy/config/application.rb +0 -22
- data/spec/dummy_engine/test/dummy/config/boot.rb +0 -5
- data/spec/dummy_engine/test/dummy/config/database.yml +0 -25
- data/spec/dummy_engine/test/dummy/config/environment.rb +0 -5
- data/spec/dummy_engine/test/dummy/config/environments/development.rb +0 -37
- data/spec/dummy_engine/test/dummy/config/environments/production.rb +0 -78
- data/spec/dummy_engine/test/dummy/config/environments/test.rb +0 -39
- data/spec/dummy_engine/test/dummy/config/initializers/assets.rb +0 -8
- data/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy_engine/test/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy_engine/test/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy_engine/test/dummy/config/locales/en.yml +0 -23
- data/spec/dummy_engine/test/dummy/config/routes.rb +0 -56
- data/spec/dummy_engine/test/dummy/config/secrets.yml +0 -22
- data/spec/examples/connection_adapter_examples.rb +0 -42
- data/spec/examples/generic_adapter_custom_configuration_example.rb +0 -95
- data/spec/examples/generic_adapter_examples.rb +0 -163
- data/spec/examples/schema_adapter_examples.rb +0 -234
- data/spec/integration/apartment_rake_integration_spec.rb +0 -107
- data/spec/integration/query_caching_spec.rb +0 -81
- data/spec/integration/use_within_an_engine_spec.rb +0 -28
- data/spec/schemas/v1.rb +0 -16
- data/spec/schemas/v2.rb +0 -43
- data/spec/schemas/v3.rb +0 -49
- data/spec/spec_helper.rb +0 -61
- data/spec/support/apartment_helpers.rb +0 -43
- data/spec/support/capybara_sessions.rb +0 -15
- data/spec/support/config.rb +0 -10
- data/spec/support/contexts.rb +0 -52
- data/spec/support/requirements.rb +0 -35
- data/spec/support/setup.rb +0 -46
- data/spec/tasks/apartment_rake_spec.rb +0 -129
- data/spec/tenant_spec.rb +0 -190
- data/spec/unit/config_spec.rb +0 -112
- data/spec/unit/elevators/domain_spec.rb +0 -32
- data/spec/unit/elevators/first_subdomain_spec.rb +0 -24
- data/spec/unit/elevators/generic_spec.rb +0 -54
- data/spec/unit/elevators/host_hash_spec.rb +0 -32
- data/spec/unit/elevators/host_spec.rb +0 -89
- data/spec/unit/elevators/subdomain_spec.rb +0 -76
- data/spec/unit/migrator_spec.rb +0 -77
- data/spec/unit/reloader_spec.rb +0 -24
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'apartment/elevators/generic'
|
|
2
4
|
|
|
3
5
|
module Apartment
|
|
@@ -12,8 +14,10 @@ module Apartment
|
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
def parse_tenant_name(request)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
unless @hash.key?(request.host)
|
|
18
|
+
raise TenantNotFound,
|
|
19
|
+
"Cannot find tenant for host #{request.host}"
|
|
20
|
+
end
|
|
17
21
|
|
|
18
22
|
@hash[request.host]
|
|
19
23
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'apartment/elevators/generic'
|
|
2
4
|
require 'public_suffix'
|
|
3
5
|
|
|
@@ -11,9 +13,11 @@ module Apartment
|
|
|
11
13
|
@excluded_subdomains ||= []
|
|
12
14
|
end
|
|
13
15
|
|
|
16
|
+
# rubocop:disable Style/TrivialAccessors
|
|
14
17
|
def self.excluded_subdomains=(arg)
|
|
15
18
|
@excluded_subdomains = arg
|
|
16
19
|
end
|
|
20
|
+
# rubocop:enable Style/TrivialAccessors
|
|
17
21
|
|
|
18
22
|
def parse_tenant_name(request)
|
|
19
23
|
request_subdomain = subdomain(request.host)
|
|
@@ -21,15 +25,15 @@ module Apartment
|
|
|
21
25
|
# If the domain acquired is set to be excluded, set the tenant to whatever is currently
|
|
22
26
|
# next in line in the schema search path.
|
|
23
27
|
tenant = if self.class.excluded_subdomains.include?(request_subdomain)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
nil
|
|
29
|
+
else
|
|
30
|
+
request_subdomain
|
|
31
|
+
end
|
|
28
32
|
|
|
29
33
|
tenant.presence
|
|
30
34
|
end
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
protected
|
|
33
37
|
|
|
34
38
|
# *Almost* a direct ripoff of ActionDispatch::Request subdomain methods
|
|
35
39
|
|
data/lib/apartment/migrator.rb
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'apartment/tenant'
|
|
2
4
|
|
|
3
5
|
module Apartment
|
|
4
6
|
module Migrator
|
|
5
|
-
|
|
6
7
|
extend self
|
|
7
8
|
|
|
8
9
|
# Migrate to latest
|
|
9
10
|
def migrate(database)
|
|
10
11
|
Tenant.switch(database) do
|
|
11
|
-
version = ENV[
|
|
12
|
+
version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
|
|
12
13
|
|
|
13
|
-
migration_scope_block = ->
|
|
14
|
+
migration_scope_block = ->(migration) { ENV['SCOPE'].blank? || (ENV['SCOPE'] == migration.scope) }
|
|
14
15
|
|
|
15
16
|
if activerecord_below_5_2?
|
|
16
17
|
ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, version, &migration_scope_block)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Apartment
|
|
4
|
+
module Model
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
module ClassMethods
|
|
8
|
+
# NOTE: key can either be an array of symbols or a single value.
|
|
9
|
+
# E.g. If we run the following query:
|
|
10
|
+
# `Setting.find_by(key: 'something', value: 'amazing')` key will have an array of symbols: `[:key, :something]`
|
|
11
|
+
# while if we run:
|
|
12
|
+
# `Setting.find(10)` key will have the value 'id'
|
|
13
|
+
def cached_find_by_statement(key, &block)
|
|
14
|
+
# Modifying the cache key to have a reference to the current tenant,
|
|
15
|
+
# so the cached statement is referring only to the tenant in which we've
|
|
16
|
+
# executed this
|
|
17
|
+
cache_key = if key.is_a? String
|
|
18
|
+
"#{Apartment::Tenant.current}_#{key}"
|
|
19
|
+
else
|
|
20
|
+
[Apartment::Tenant.current] + key
|
|
21
|
+
end
|
|
22
|
+
cache = @find_by_statement_cache[connection.prepared_statements]
|
|
23
|
+
cache.compute_if_absent(cache_key) { ActiveRecord::StatementCache.create(connection, &block) }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/apartment/railtie.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rails'
|
|
2
4
|
require 'apartment/tenant'
|
|
3
5
|
require 'apartment/reloader'
|
|
4
6
|
|
|
5
7
|
module Apartment
|
|
6
8
|
class Railtie < Rails::Railtie
|
|
7
|
-
|
|
8
9
|
#
|
|
9
10
|
# Set up our default config options
|
|
10
11
|
# Do this before the app initializers run so we don't override custom settings
|
|
@@ -17,27 +18,34 @@ module Apartment
|
|
|
17
18
|
config.seed_after_create = false
|
|
18
19
|
config.prepend_environment = false
|
|
19
20
|
config.append_environment = false
|
|
21
|
+
config.tenant_presence_check = true
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
ActiveRecord::Migrator.migrations_paths = Rails.application.paths['db/migrate'].to_a
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
#
|
|
26
|
-
# Note that this doens't entirely work as expected in Development, because this is called before classes are reloaded
|
|
27
|
-
# See the middleware/console declarations below to help with this. Hope to fix that soon.
|
|
28
|
-
#
|
|
27
|
+
# Make sure Apartment is reconfigured when the code is reloaded
|
|
29
28
|
config.to_prepare do
|
|
30
|
-
|
|
29
|
+
Apartment::Tenant.reinitialize
|
|
30
|
+
end
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
#
|
|
33
|
+
# Ensure that Apartment::Tenant.init is called when
|
|
34
|
+
# a new connection is requested.
|
|
35
|
+
#
|
|
36
|
+
module ApartmentInitializer
|
|
37
|
+
def connection
|
|
38
|
+
super.tap do
|
|
39
|
+
Apartment::Tenant.init_once
|
|
35
40
|
end
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def arel_table
|
|
44
|
+
Apartment::Tenant.init_once
|
|
45
|
+
super
|
|
39
46
|
end
|
|
40
47
|
end
|
|
48
|
+
ActiveRecord::Base.singleton_class.prepend ApartmentInitializer
|
|
41
49
|
|
|
42
50
|
#
|
|
43
51
|
# Ensure rake tasks are loaded
|
|
@@ -48,8 +56,10 @@ module Apartment
|
|
|
48
56
|
end
|
|
49
57
|
|
|
50
58
|
#
|
|
51
|
-
# The following initializers are a workaround to the fact that I can't
|
|
52
|
-
#
|
|
59
|
+
# The following initializers are a workaround to the fact that I can't
|
|
60
|
+
# properly hook into the rails reloader
|
|
61
|
+
# Note this is technically valid for any environment where cache_classes
|
|
62
|
+
# is false, for us, it's just development
|
|
53
63
|
#
|
|
54
64
|
if Rails.env.development?
|
|
55
65
|
|
|
@@ -58,7 +68,8 @@ module Apartment
|
|
|
58
68
|
app.config.middleware.use Apartment::Reloader
|
|
59
69
|
end
|
|
60
70
|
|
|
61
|
-
# Overrides reload! to also call Apartment::Tenant.init as well so that the
|
|
71
|
+
# Overrides reload! to also call Apartment::Tenant.init as well so that the
|
|
72
|
+
# reloaded classes have the proper table_names
|
|
62
73
|
console do
|
|
63
74
|
require 'apartment/console'
|
|
64
75
|
end
|
data/lib/apartment/reloader.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Apartment
|
|
2
4
|
class Reloader
|
|
3
|
-
|
|
4
5
|
# Middleware used in development to init Apartment for each request
|
|
5
6
|
# Necessary due to code reload (annoying). When models are reloaded, they no longer have the proper table_name
|
|
6
7
|
# That is prepended with the schema (if using postgresql schemas)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Require this file to append Apartment rake tasks to ActiveRecord db rake tasks
|
|
2
4
|
# Enabled by default in the initializer
|
|
3
5
|
|
|
4
6
|
module Apartment
|
|
5
7
|
class RakeTaskEnhancer
|
|
6
|
-
|
|
7
8
|
module TASKS
|
|
8
|
-
ENHANCE_BEFORE = %w
|
|
9
|
-
ENHANCE_AFTER = %w
|
|
9
|
+
ENHANCE_BEFORE = %w[db:drop].freeze
|
|
10
|
+
ENHANCE_AFTER = %w[db:create db:migrate db:rollback db:migrate:up db:migrate:down db:migrate:redo db:seed].freeze
|
|
10
11
|
freeze
|
|
11
12
|
end
|
|
12
13
|
|
|
@@ -28,7 +29,6 @@ module Apartment
|
|
|
28
29
|
task = Rake::Task[name]
|
|
29
30
|
enhance_after_task(task)
|
|
30
31
|
end
|
|
31
|
-
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def should_enhance?
|
|
@@ -48,9 +48,7 @@ module Apartment
|
|
|
48
48
|
def inserted_task_name(task)
|
|
49
49
|
task.name.sub(/db:/, 'apartment:')
|
|
50
50
|
end
|
|
51
|
-
|
|
52
51
|
end
|
|
53
|
-
|
|
54
52
|
end
|
|
55
53
|
end
|
|
56
54
|
|
data/lib/apartment/tenant.rb
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'forwardable'
|
|
2
4
|
|
|
3
5
|
module Apartment
|
|
4
6
|
# The main entry point to Apartment functions
|
|
5
7
|
#
|
|
6
8
|
module Tenant
|
|
7
|
-
|
|
8
9
|
extend self
|
|
9
10
|
extend Forwardable
|
|
10
11
|
|
|
11
|
-
def_delegators :adapter, :create, :drop, :switch, :switch!, :current, :each,
|
|
12
|
+
def_delegators :adapter, :create, :drop, :switch, :switch!, :current, :each,
|
|
13
|
+
:reset, :init, :set_callback, :seed, :current_tenant,
|
|
14
|
+
:default_tenant, :environmentify
|
|
12
15
|
|
|
13
16
|
attr_writer :config
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
def init_once
|
|
19
|
+
return if @already_initialized
|
|
20
|
+
|
|
21
|
+
# To avoid infinite loops in work init is doing,
|
|
22
|
+
# we need to set @already_initialized to true
|
|
23
|
+
# before init is called
|
|
24
|
+
@already_initialized = true
|
|
25
|
+
init
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def reinitialize
|
|
29
|
+
@already_initialized = false
|
|
19
30
|
end
|
|
20
31
|
|
|
21
32
|
# Fetch the proper multi-tenant adapter based on Rails config
|
|
@@ -40,9 +51,7 @@ module Apartment
|
|
|
40
51
|
raise "The adapter `#{adapter_method}` is not yet supported"
|
|
41
52
|
end
|
|
42
53
|
|
|
43
|
-
unless respond_to?(adapter_method)
|
|
44
|
-
raise AdapterNotFound, "database configuration specifies nonexistent #{config[:adapter]} adapter"
|
|
45
|
-
end
|
|
54
|
+
raise AdapterNotFound, "database configuration specifies nonexistent #{config[:adapter]} adapter" unless respond_to?(adapter_method)
|
|
46
55
|
|
|
47
56
|
send(adapter_method, config)
|
|
48
57
|
end
|
|
@@ -52,6 +61,7 @@ module Apartment
|
|
|
52
61
|
#
|
|
53
62
|
def reload!(config = nil)
|
|
54
63
|
Thread.current[:apartment_adapter] = nil
|
|
64
|
+
reinitialize
|
|
55
65
|
@config = config
|
|
56
66
|
end
|
|
57
67
|
|
data/lib/apartment/version.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Apartment
|
|
2
4
|
class InstallGenerator < Rails::Generators::Base
|
|
3
|
-
source_root File.expand_path('
|
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
|
4
6
|
|
|
5
7
|
def copy_files
|
|
6
|
-
template
|
|
8
|
+
template 'apartment.rb', File.join('config', 'initializers', 'apartment.rb')
|
|
7
9
|
end
|
|
8
|
-
|
|
9
10
|
end
|
|
10
11
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# You can have Apartment route to the appropriate Tenant by adding some Rack middleware.
|
|
2
4
|
# Apartment can support many different "Elevators" that can take care of this routing to your data.
|
|
3
5
|
# Require whichever Elevator you're using below or none if you have a custom one.
|
|
@@ -12,7 +14,6 @@ require 'apartment/elevators/subdomain'
|
|
|
12
14
|
# Apartment Configuration
|
|
13
15
|
#
|
|
14
16
|
Apartment.configure do |config|
|
|
15
|
-
|
|
16
17
|
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
|
|
17
18
|
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
|
|
18
19
|
#
|
|
@@ -48,7 +49,7 @@ Apartment.configure do |config|
|
|
|
48
49
|
# end
|
|
49
50
|
# end
|
|
50
51
|
#
|
|
51
|
-
config.tenant_names =
|
|
52
|
+
config.tenant_names = -> { ToDo_Tenant_Or_User_Model.pluck :database }
|
|
52
53
|
|
|
53
54
|
# PostgreSQL:
|
|
54
55
|
# Specifies whether to use PostgreSQL schemas or create a new database per Tenant.
|
data/lib/tasks/apartment.rake
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'apartment/migrator'
|
|
2
4
|
require 'parallel'
|
|
3
5
|
|
|
4
6
|
apartment_namespace = namespace :apartment do
|
|
5
|
-
|
|
6
|
-
desc "Create all tenants"
|
|
7
|
+
desc 'Create all tenants'
|
|
7
8
|
task :create do
|
|
8
9
|
tenants.each do |tenant|
|
|
9
10
|
begin
|
|
@@ -15,19 +16,19 @@ apartment_namespace = namespace :apartment do
|
|
|
15
16
|
end
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
desc
|
|
19
|
+
desc 'Drop all tenants'
|
|
19
20
|
task :drop do
|
|
20
21
|
tenants.each do |tenant|
|
|
21
22
|
begin
|
|
22
23
|
puts("Dropping #{tenant} tenant")
|
|
23
24
|
Apartment::Tenant.drop(tenant)
|
|
24
|
-
rescue Apartment::TenantNotFound => e
|
|
25
|
+
rescue Apartment::TenantNotFound, ActiveRecord::NoDatabaseError => e
|
|
25
26
|
puts e.message
|
|
26
27
|
end
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
|
|
30
|
-
desc
|
|
31
|
+
desc 'Migrate all tenants'
|
|
31
32
|
task :migrate do
|
|
32
33
|
warn_if_tenants_empty
|
|
33
34
|
each_tenant do |tenant|
|
|
@@ -40,7 +41,7 @@ apartment_namespace = namespace :apartment do
|
|
|
40
41
|
end
|
|
41
42
|
end
|
|
42
43
|
|
|
43
|
-
desc
|
|
44
|
+
desc 'Seed all tenants'
|
|
44
45
|
task :seed do
|
|
45
46
|
warn_if_tenants_empty
|
|
46
47
|
|
|
@@ -56,7 +57,7 @@ apartment_namespace = namespace :apartment do
|
|
|
56
57
|
end
|
|
57
58
|
end
|
|
58
59
|
|
|
59
|
-
desc
|
|
60
|
+
desc 'Rolls the migration back to the previous version (specify steps w/ STEP=n) across all tenants.'
|
|
60
61
|
task :rollback do
|
|
61
62
|
warn_if_tenants_empty
|
|
62
63
|
|
|
@@ -107,7 +108,7 @@ apartment_namespace = namespace :apartment do
|
|
|
107
108
|
end
|
|
108
109
|
end
|
|
109
110
|
|
|
110
|
-
desc
|
|
111
|
+
desc 'Rolls back the tenant one migration and re migrate up (options: STEP=x, VERSION=x).'
|
|
111
112
|
task :redo do
|
|
112
113
|
if ENV['VERSION']
|
|
113
114
|
apartment_namespace['migrate:down'].invoke
|
|
@@ -120,26 +121,30 @@ apartment_namespace = namespace :apartment do
|
|
|
120
121
|
end
|
|
121
122
|
|
|
122
123
|
def each_tenant(&block)
|
|
123
|
-
Parallel.each(
|
|
124
|
+
Parallel.each(tenants_without_default, in_threads: Apartment.parallel_migration_threads) do |tenant|
|
|
124
125
|
block.call(tenant)
|
|
125
126
|
end
|
|
126
127
|
end
|
|
127
128
|
|
|
129
|
+
def tenants_without_default
|
|
130
|
+
tenants - [Apartment.default_schema]
|
|
131
|
+
end
|
|
132
|
+
|
|
128
133
|
def tenants
|
|
129
|
-
ENV['DB'] ? ENV['DB'].split(',').map
|
|
134
|
+
ENV['DB'] ? ENV['DB'].split(',').map(&:strip) : Apartment.tenant_names || []
|
|
130
135
|
end
|
|
131
136
|
|
|
132
137
|
def warn_if_tenants_empty
|
|
133
|
-
|
|
134
|
-
puts <<-WARNING
|
|
135
|
-
[WARNING] - The list of tenants to migrate appears to be empty. This could mean a few things:
|
|
138
|
+
return unless tenants.empty? && ENV['IGNORE_EMPTY_TENANTS'] != 'true'
|
|
136
139
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
* `apartment:migrate` is now deprecated. Tenants will automatically be migrated with `db:migrate`
|
|
140
|
+
puts <<-WARNING
|
|
141
|
+
[WARNING] - The list of tenants to migrate appears to be empty. This could mean a few things:
|
|
140
142
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
1. You may not have created any, in which case you can ignore this message
|
|
144
|
+
2. You've run `apartment:migrate` directly without loading the Rails environment
|
|
145
|
+
* `apartment:migrate` is now deprecated. Tenants will automatically be migrated with `db:migrate`
|
|
146
|
+
|
|
147
|
+
Note that your tenants currently haven't been migrated. You'll need to run `db:migrate` to rectify this.
|
|
148
|
+
WARNING
|
|
144
149
|
end
|
|
145
150
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ros-apartment
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Brunner
|
|
8
8
|
- Brad Robertson
|
|
9
|
+
- Rui Baltazar
|
|
9
10
|
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
12
|
-
date: 2020-
|
|
13
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
|
13
14
|
dependencies:
|
|
14
15
|
- !ruby/object:Gem::Dependency
|
|
15
16
|
name: activerecord
|
|
@@ -17,7 +18,7 @@ dependencies:
|
|
|
17
18
|
requirements:
|
|
18
19
|
- - ">="
|
|
19
20
|
- !ruby/object:Gem::Version
|
|
20
|
-
version:
|
|
21
|
+
version: 5.0.0
|
|
21
22
|
- - "<"
|
|
22
23
|
- !ruby/object:Gem::Version
|
|
23
24
|
version: '6.1'
|
|
@@ -27,170 +28,182 @@ dependencies:
|
|
|
27
28
|
requirements:
|
|
28
29
|
- - ">="
|
|
29
30
|
- !ruby/object:Gem::Version
|
|
30
|
-
version:
|
|
31
|
+
version: 5.0.0
|
|
31
32
|
- - "<"
|
|
32
33
|
- !ruby/object:Gem::Version
|
|
33
34
|
version: '6.1'
|
|
34
35
|
- !ruby/object:Gem::Dependency
|
|
35
|
-
name:
|
|
36
|
+
name: parallel
|
|
36
37
|
requirement: !ruby/object:Gem::Requirement
|
|
37
38
|
requirements:
|
|
38
|
-
- - "
|
|
39
|
+
- - "<"
|
|
39
40
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
41
|
+
version: '2.0'
|
|
41
42
|
type: :runtime
|
|
42
43
|
prerelease: false
|
|
43
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
44
45
|
requirements:
|
|
45
|
-
- - "
|
|
46
|
+
- - "<"
|
|
46
47
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
48
|
+
version: '2.0'
|
|
48
49
|
- !ruby/object:Gem::Dependency
|
|
49
50
|
name: public_suffix
|
|
50
51
|
requirement: !ruby/object:Gem::Requirement
|
|
51
52
|
requirements:
|
|
52
53
|
- - ">="
|
|
53
54
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
55
|
+
version: 2.0.5
|
|
56
|
+
- - "<"
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '5.0'
|
|
55
59
|
type: :runtime
|
|
56
60
|
prerelease: false
|
|
57
61
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
62
|
requirements:
|
|
59
63
|
- - ">="
|
|
60
64
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
65
|
+
version: 2.0.5
|
|
66
|
+
- - "<"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '5.0'
|
|
62
69
|
- !ruby/object:Gem::Dependency
|
|
63
|
-
name:
|
|
70
|
+
name: rack
|
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
|
65
72
|
requirements:
|
|
66
73
|
- - ">="
|
|
67
74
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
75
|
+
version: 1.3.6
|
|
76
|
+
- - "<"
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '3.0'
|
|
69
79
|
type: :runtime
|
|
70
80
|
prerelease: false
|
|
71
81
|
version_requirements: !ruby/object:Gem::Requirement
|
|
72
82
|
requirements:
|
|
73
83
|
- - ">="
|
|
74
84
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
85
|
+
version: 1.3.6
|
|
86
|
+
- - "<"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '3.0'
|
|
76
89
|
- !ruby/object:Gem::Dependency
|
|
77
90
|
name: appraisal
|
|
78
91
|
requirement: !ruby/object:Gem::Requirement
|
|
79
92
|
requirements:
|
|
80
|
-
- - "
|
|
93
|
+
- - "~>"
|
|
81
94
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
95
|
+
version: '2.2'
|
|
83
96
|
type: :development
|
|
84
97
|
prerelease: false
|
|
85
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
86
99
|
requirements:
|
|
87
|
-
- - "
|
|
100
|
+
- - "~>"
|
|
88
101
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
102
|
+
version: '2.2'
|
|
90
103
|
- !ruby/object:Gem::Dependency
|
|
91
|
-
name:
|
|
104
|
+
name: bundler
|
|
92
105
|
requirement: !ruby/object:Gem::Requirement
|
|
93
106
|
requirements:
|
|
94
|
-
- - "
|
|
107
|
+
- - ">="
|
|
95
108
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
109
|
+
version: '1.3'
|
|
110
|
+
- - "<"
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '3.0'
|
|
97
113
|
type: :development
|
|
98
114
|
prerelease: false
|
|
99
115
|
version_requirements: !ruby/object:Gem::Requirement
|
|
100
116
|
requirements:
|
|
101
|
-
- - "
|
|
117
|
+
- - ">="
|
|
102
118
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
119
|
+
version: '1.3'
|
|
120
|
+
- - "<"
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '3.0'
|
|
104
123
|
- !ruby/object:Gem::Dependency
|
|
105
|
-
name:
|
|
124
|
+
name: capybara
|
|
106
125
|
requirement: !ruby/object:Gem::Requirement
|
|
107
126
|
requirements:
|
|
108
127
|
- - "~>"
|
|
109
128
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
129
|
+
version: '2.0'
|
|
111
130
|
type: :development
|
|
112
131
|
prerelease: false
|
|
113
132
|
version_requirements: !ruby/object:Gem::Requirement
|
|
114
133
|
requirements:
|
|
115
134
|
- - "~>"
|
|
116
135
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '
|
|
136
|
+
version: '2.0'
|
|
118
137
|
- !ruby/object:Gem::Dependency
|
|
119
|
-
name:
|
|
138
|
+
name: rake
|
|
120
139
|
requirement: !ruby/object:Gem::Requirement
|
|
121
140
|
requirements:
|
|
122
141
|
- - "~>"
|
|
123
142
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '
|
|
143
|
+
version: '0.9'
|
|
125
144
|
type: :development
|
|
126
145
|
prerelease: false
|
|
127
146
|
version_requirements: !ruby/object:Gem::Requirement
|
|
128
147
|
requirements:
|
|
129
148
|
- - "~>"
|
|
130
149
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '
|
|
150
|
+
version: '0.9'
|
|
132
151
|
- !ruby/object:Gem::Dependency
|
|
133
|
-
name:
|
|
152
|
+
name: rspec
|
|
134
153
|
requirement: !ruby/object:Gem::Requirement
|
|
135
154
|
requirements:
|
|
136
155
|
- - "~>"
|
|
137
156
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '
|
|
157
|
+
version: '3.4'
|
|
139
158
|
type: :development
|
|
140
159
|
prerelease: false
|
|
141
160
|
version_requirements: !ruby/object:Gem::Requirement
|
|
142
161
|
requirements:
|
|
143
162
|
- - "~>"
|
|
144
163
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '
|
|
164
|
+
version: '3.4'
|
|
146
165
|
- !ruby/object:Gem::Dependency
|
|
147
|
-
name:
|
|
166
|
+
name: rspec-rails
|
|
148
167
|
requirement: !ruby/object:Gem::Requirement
|
|
149
168
|
requirements:
|
|
150
|
-
- - "
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
version: '1.3'
|
|
153
|
-
- - "<"
|
|
169
|
+
- - "~>"
|
|
154
170
|
- !ruby/object:Gem::Version
|
|
155
|
-
version: '
|
|
171
|
+
version: '3.4'
|
|
156
172
|
type: :development
|
|
157
173
|
prerelease: false
|
|
158
174
|
version_requirements: !ruby/object:Gem::Requirement
|
|
159
175
|
requirements:
|
|
160
|
-
- - "
|
|
161
|
-
- !ruby/object:Gem::Version
|
|
162
|
-
version: '1.3'
|
|
163
|
-
- - "<"
|
|
176
|
+
- - "~>"
|
|
164
177
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: '
|
|
178
|
+
version: '3.4'
|
|
166
179
|
- !ruby/object:Gem::Dependency
|
|
167
180
|
name: mysql2
|
|
168
181
|
requirement: !ruby/object:Gem::Requirement
|
|
169
182
|
requirements:
|
|
170
|
-
- - "
|
|
183
|
+
- - "~>"
|
|
171
184
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: '0'
|
|
185
|
+
version: '0.5'
|
|
173
186
|
type: :development
|
|
174
187
|
prerelease: false
|
|
175
188
|
version_requirements: !ruby/object:Gem::Requirement
|
|
176
189
|
requirements:
|
|
177
|
-
- - "
|
|
190
|
+
- - "~>"
|
|
178
191
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: '0'
|
|
192
|
+
version: '0.5'
|
|
180
193
|
- !ruby/object:Gem::Dependency
|
|
181
194
|
name: pg
|
|
182
195
|
requirement: !ruby/object:Gem::Requirement
|
|
183
196
|
requirements:
|
|
184
|
-
- - "
|
|
197
|
+
- - "~>"
|
|
185
198
|
- !ruby/object:Gem::Version
|
|
186
|
-
version: '
|
|
199
|
+
version: '1.2'
|
|
187
200
|
type: :development
|
|
188
201
|
prerelease: false
|
|
189
202
|
version_requirements: !ruby/object:Gem::Requirement
|
|
190
203
|
requirements:
|
|
191
|
-
- - "
|
|
204
|
+
- - "~>"
|
|
192
205
|
- !ruby/object:Gem::Version
|
|
193
|
-
version: '
|
|
206
|
+
version: '1.2'
|
|
194
207
|
- !ruby/object:Gem::Dependency
|
|
195
208
|
name: sqlite3
|
|
196
209
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -210,14 +223,19 @@ description: Apartment allows Rack applications to deal with database multitenan
|
|
|
210
223
|
email:
|
|
211
224
|
- ryan@influitive.com
|
|
212
225
|
- brad@influitive.com
|
|
226
|
+
- rui.p.baltazar@gmail.com
|
|
213
227
|
executables: []
|
|
214
228
|
extensions: []
|
|
215
229
|
extra_rdoc_files: []
|
|
216
230
|
files:
|
|
217
231
|
- ".github/ISSUE_TEMPLATE.md"
|
|
232
|
+
- ".github/workflows/.rubocop-linter.yml"
|
|
218
233
|
- ".gitignore"
|
|
219
234
|
- ".pryrc"
|
|
220
235
|
- ".rspec"
|
|
236
|
+
- ".rubocop.yml"
|
|
237
|
+
- ".rubocop_todo.yml"
|
|
238
|
+
- ".story_branch.yml"
|
|
221
239
|
- ".travis.yml"
|
|
222
240
|
- Appraisals
|
|
223
241
|
- Gemfile
|
|
@@ -235,6 +253,9 @@ files:
|
|
|
235
253
|
- gemfiles/rails_6_0.gemfile
|
|
236
254
|
- gemfiles/rails_master.gemfile
|
|
237
255
|
- lib/apartment.rb
|
|
256
|
+
- lib/apartment/active_record/connection_handling.rb
|
|
257
|
+
- lib/apartment/active_record/internal_metadata.rb
|
|
258
|
+
- lib/apartment/active_record/schema_migration.rb
|
|
238
259
|
- lib/apartment/adapters/abstract_adapter.rb
|
|
239
260
|
- lib/apartment/adapters/abstract_jdbc_adapter.rb
|
|
240
261
|
- lib/apartment/adapters/jdbc_mysql_adapter.rb
|
|
@@ -244,6 +265,7 @@ files:
|
|
|
244
265
|
- lib/apartment/adapters/postgresql_adapter.rb
|
|
245
266
|
- lib/apartment/adapters/sqlite3_adapter.rb
|
|
246
267
|
- lib/apartment/console.rb
|
|
268
|
+
- lib/apartment/custom_console.rb
|
|
247
269
|
- lib/apartment/deprecation.rb
|
|
248
270
|
- lib/apartment/elevators/domain.rb
|
|
249
271
|
- lib/apartment/elevators/first_subdomain.rb
|
|
@@ -252,6 +274,7 @@ files:
|
|
|
252
274
|
- lib/apartment/elevators/host_hash.rb
|
|
253
275
|
- lib/apartment/elevators/subdomain.rb
|
|
254
276
|
- lib/apartment/migrator.rb
|
|
277
|
+
- lib/apartment/model.rb
|
|
255
278
|
- lib/apartment/railtie.rb
|
|
256
279
|
- lib/apartment/reloader.rb
|
|
257
280
|
- lib/apartment/tasks/enhancements.rb
|
|
@@ -261,106 +284,6 @@ files:
|
|
|
261
284
|
- lib/generators/apartment/install/install_generator.rb
|
|
262
285
|
- lib/generators/apartment/install/templates/apartment.rb
|
|
263
286
|
- lib/tasks/apartment.rake
|
|
264
|
-
- spec/adapters/jdbc_mysql_adapter_spec.rb
|
|
265
|
-
- spec/adapters/jdbc_postgresql_adapter_spec.rb
|
|
266
|
-
- spec/adapters/mysql2_adapter_spec.rb
|
|
267
|
-
- spec/adapters/postgresql_adapter_spec.rb
|
|
268
|
-
- spec/adapters/sqlite3_adapter_spec.rb
|
|
269
|
-
- spec/apartment_spec.rb
|
|
270
|
-
- spec/config/database.yml.sample
|
|
271
|
-
- spec/dummy/Rakefile
|
|
272
|
-
- spec/dummy/app/controllers/application_controller.rb
|
|
273
|
-
- spec/dummy/app/helpers/application_helper.rb
|
|
274
|
-
- spec/dummy/app/models/company.rb
|
|
275
|
-
- spec/dummy/app/models/user.rb
|
|
276
|
-
- spec/dummy/app/views/application/index.html.erb
|
|
277
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
|
278
|
-
- spec/dummy/config.ru
|
|
279
|
-
- spec/dummy/config/application.rb
|
|
280
|
-
- spec/dummy/config/boot.rb
|
|
281
|
-
- spec/dummy/config/database.yml.sample
|
|
282
|
-
- spec/dummy/config/environment.rb
|
|
283
|
-
- spec/dummy/config/environments/development.rb
|
|
284
|
-
- spec/dummy/config/environments/production.rb
|
|
285
|
-
- spec/dummy/config/environments/test.rb
|
|
286
|
-
- spec/dummy/config/initializers/apartment.rb
|
|
287
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
|
288
|
-
- spec/dummy/config/initializers/inflections.rb
|
|
289
|
-
- spec/dummy/config/initializers/mime_types.rb
|
|
290
|
-
- spec/dummy/config/initializers/secret_token.rb
|
|
291
|
-
- spec/dummy/config/initializers/session_store.rb
|
|
292
|
-
- spec/dummy/config/locales/en.yml
|
|
293
|
-
- spec/dummy/config/routes.rb
|
|
294
|
-
- spec/dummy/db/migrate/20110613152810_create_dummy_models.rb
|
|
295
|
-
- spec/dummy/db/migrate/20111202022214_create_table_books.rb
|
|
296
|
-
- spec/dummy/db/migrate/20180415260934_create_public_tokens.rb
|
|
297
|
-
- spec/dummy/db/schema.rb
|
|
298
|
-
- spec/dummy/db/seeds.rb
|
|
299
|
-
- spec/dummy/db/seeds/import.rb
|
|
300
|
-
- spec/dummy/db/test.sqlite3
|
|
301
|
-
- spec/dummy/public/404.html
|
|
302
|
-
- spec/dummy/public/422.html
|
|
303
|
-
- spec/dummy/public/500.html
|
|
304
|
-
- spec/dummy/public/favicon.ico
|
|
305
|
-
- spec/dummy/public/stylesheets/.gitkeep
|
|
306
|
-
- spec/dummy/script/rails
|
|
307
|
-
- spec/dummy_engine/.gitignore
|
|
308
|
-
- spec/dummy_engine/Gemfile
|
|
309
|
-
- spec/dummy_engine/Rakefile
|
|
310
|
-
- spec/dummy_engine/bin/rails
|
|
311
|
-
- spec/dummy_engine/config/initializers/apartment.rb
|
|
312
|
-
- spec/dummy_engine/dummy_engine.gemspec
|
|
313
|
-
- spec/dummy_engine/lib/dummy_engine.rb
|
|
314
|
-
- spec/dummy_engine/lib/dummy_engine/engine.rb
|
|
315
|
-
- spec/dummy_engine/lib/dummy_engine/version.rb
|
|
316
|
-
- spec/dummy_engine/test/dummy/Rakefile
|
|
317
|
-
- spec/dummy_engine/test/dummy/config.ru
|
|
318
|
-
- spec/dummy_engine/test/dummy/config/application.rb
|
|
319
|
-
- spec/dummy_engine/test/dummy/config/boot.rb
|
|
320
|
-
- spec/dummy_engine/test/dummy/config/database.yml
|
|
321
|
-
- spec/dummy_engine/test/dummy/config/environment.rb
|
|
322
|
-
- spec/dummy_engine/test/dummy/config/environments/development.rb
|
|
323
|
-
- spec/dummy_engine/test/dummy/config/environments/production.rb
|
|
324
|
-
- spec/dummy_engine/test/dummy/config/environments/test.rb
|
|
325
|
-
- spec/dummy_engine/test/dummy/config/initializers/assets.rb
|
|
326
|
-
- spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb
|
|
327
|
-
- spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb
|
|
328
|
-
- spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb
|
|
329
|
-
- spec/dummy_engine/test/dummy/config/initializers/inflections.rb
|
|
330
|
-
- spec/dummy_engine/test/dummy/config/initializers/mime_types.rb
|
|
331
|
-
- spec/dummy_engine/test/dummy/config/initializers/session_store.rb
|
|
332
|
-
- spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb
|
|
333
|
-
- spec/dummy_engine/test/dummy/config/locales/en.yml
|
|
334
|
-
- spec/dummy_engine/test/dummy/config/routes.rb
|
|
335
|
-
- spec/dummy_engine/test/dummy/config/secrets.yml
|
|
336
|
-
- spec/examples/connection_adapter_examples.rb
|
|
337
|
-
- spec/examples/generic_adapter_custom_configuration_example.rb
|
|
338
|
-
- spec/examples/generic_adapter_examples.rb
|
|
339
|
-
- spec/examples/schema_adapter_examples.rb
|
|
340
|
-
- spec/integration/apartment_rake_integration_spec.rb
|
|
341
|
-
- spec/integration/query_caching_spec.rb
|
|
342
|
-
- spec/integration/use_within_an_engine_spec.rb
|
|
343
|
-
- spec/schemas/v1.rb
|
|
344
|
-
- spec/schemas/v2.rb
|
|
345
|
-
- spec/schemas/v3.rb
|
|
346
|
-
- spec/spec_helper.rb
|
|
347
|
-
- spec/support/apartment_helpers.rb
|
|
348
|
-
- spec/support/capybara_sessions.rb
|
|
349
|
-
- spec/support/config.rb
|
|
350
|
-
- spec/support/contexts.rb
|
|
351
|
-
- spec/support/requirements.rb
|
|
352
|
-
- spec/support/setup.rb
|
|
353
|
-
- spec/tasks/apartment_rake_spec.rb
|
|
354
|
-
- spec/tenant_spec.rb
|
|
355
|
-
- spec/unit/config_spec.rb
|
|
356
|
-
- spec/unit/elevators/domain_spec.rb
|
|
357
|
-
- spec/unit/elevators/first_subdomain_spec.rb
|
|
358
|
-
- spec/unit/elevators/generic_spec.rb
|
|
359
|
-
- spec/unit/elevators/host_hash_spec.rb
|
|
360
|
-
- spec/unit/elevators/host_spec.rb
|
|
361
|
-
- spec/unit/elevators/subdomain_spec.rb
|
|
362
|
-
- spec/unit/migrator_spec.rb
|
|
363
|
-
- spec/unit/reloader_spec.rb
|
|
364
287
|
homepage: https://github.com/rails-on-services/apartment
|
|
365
288
|
licenses:
|
|
366
289
|
- MIT
|
|
@@ -376,112 +299,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
376
299
|
version: '0'
|
|
377
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
378
301
|
requirements:
|
|
379
|
-
- - "
|
|
302
|
+
- - ">="
|
|
380
303
|
- !ruby/object:Gem::Version
|
|
381
|
-
version:
|
|
304
|
+
version: '0'
|
|
382
305
|
requirements: []
|
|
383
|
-
rubygems_version: 3.0.
|
|
306
|
+
rubygems_version: 3.0.3
|
|
384
307
|
signing_key:
|
|
385
308
|
specification_version: 4
|
|
386
|
-
summary: A Ruby gem for managing database multitenancy
|
|
387
|
-
test_files:
|
|
388
|
-
- spec/adapters/jdbc_mysql_adapter_spec.rb
|
|
389
|
-
- spec/adapters/jdbc_postgresql_adapter_spec.rb
|
|
390
|
-
- spec/adapters/mysql2_adapter_spec.rb
|
|
391
|
-
- spec/adapters/postgresql_adapter_spec.rb
|
|
392
|
-
- spec/adapters/sqlite3_adapter_spec.rb
|
|
393
|
-
- spec/apartment_spec.rb
|
|
394
|
-
- spec/config/database.yml.sample
|
|
395
|
-
- spec/dummy/Rakefile
|
|
396
|
-
- spec/dummy/app/controllers/application_controller.rb
|
|
397
|
-
- spec/dummy/app/helpers/application_helper.rb
|
|
398
|
-
- spec/dummy/app/models/company.rb
|
|
399
|
-
- spec/dummy/app/models/user.rb
|
|
400
|
-
- spec/dummy/app/views/application/index.html.erb
|
|
401
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
|
402
|
-
- spec/dummy/config.ru
|
|
403
|
-
- spec/dummy/config/application.rb
|
|
404
|
-
- spec/dummy/config/boot.rb
|
|
405
|
-
- spec/dummy/config/database.yml.sample
|
|
406
|
-
- spec/dummy/config/environment.rb
|
|
407
|
-
- spec/dummy/config/environments/development.rb
|
|
408
|
-
- spec/dummy/config/environments/production.rb
|
|
409
|
-
- spec/dummy/config/environments/test.rb
|
|
410
|
-
- spec/dummy/config/initializers/apartment.rb
|
|
411
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
|
412
|
-
- spec/dummy/config/initializers/inflections.rb
|
|
413
|
-
- spec/dummy/config/initializers/mime_types.rb
|
|
414
|
-
- spec/dummy/config/initializers/secret_token.rb
|
|
415
|
-
- spec/dummy/config/initializers/session_store.rb
|
|
416
|
-
- spec/dummy/config/locales/en.yml
|
|
417
|
-
- spec/dummy/config/routes.rb
|
|
418
|
-
- spec/dummy/db/migrate/20110613152810_create_dummy_models.rb
|
|
419
|
-
- spec/dummy/db/migrate/20111202022214_create_table_books.rb
|
|
420
|
-
- spec/dummy/db/migrate/20180415260934_create_public_tokens.rb
|
|
421
|
-
- spec/dummy/db/schema.rb
|
|
422
|
-
- spec/dummy/db/seeds.rb
|
|
423
|
-
- spec/dummy/db/seeds/import.rb
|
|
424
|
-
- spec/dummy/db/test.sqlite3
|
|
425
|
-
- spec/dummy/public/404.html
|
|
426
|
-
- spec/dummy/public/422.html
|
|
427
|
-
- spec/dummy/public/500.html
|
|
428
|
-
- spec/dummy/public/favicon.ico
|
|
429
|
-
- spec/dummy/public/stylesheets/.gitkeep
|
|
430
|
-
- spec/dummy/script/rails
|
|
431
|
-
- spec/dummy_engine/.gitignore
|
|
432
|
-
- spec/dummy_engine/Gemfile
|
|
433
|
-
- spec/dummy_engine/Rakefile
|
|
434
|
-
- spec/dummy_engine/bin/rails
|
|
435
|
-
- spec/dummy_engine/config/initializers/apartment.rb
|
|
436
|
-
- spec/dummy_engine/dummy_engine.gemspec
|
|
437
|
-
- spec/dummy_engine/lib/dummy_engine.rb
|
|
438
|
-
- spec/dummy_engine/lib/dummy_engine/engine.rb
|
|
439
|
-
- spec/dummy_engine/lib/dummy_engine/version.rb
|
|
440
|
-
- spec/dummy_engine/test/dummy/Rakefile
|
|
441
|
-
- spec/dummy_engine/test/dummy/config.ru
|
|
442
|
-
- spec/dummy_engine/test/dummy/config/application.rb
|
|
443
|
-
- spec/dummy_engine/test/dummy/config/boot.rb
|
|
444
|
-
- spec/dummy_engine/test/dummy/config/database.yml
|
|
445
|
-
- spec/dummy_engine/test/dummy/config/environment.rb
|
|
446
|
-
- spec/dummy_engine/test/dummy/config/environments/development.rb
|
|
447
|
-
- spec/dummy_engine/test/dummy/config/environments/production.rb
|
|
448
|
-
- spec/dummy_engine/test/dummy/config/environments/test.rb
|
|
449
|
-
- spec/dummy_engine/test/dummy/config/initializers/assets.rb
|
|
450
|
-
- spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb
|
|
451
|
-
- spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb
|
|
452
|
-
- spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb
|
|
453
|
-
- spec/dummy_engine/test/dummy/config/initializers/inflections.rb
|
|
454
|
-
- spec/dummy_engine/test/dummy/config/initializers/mime_types.rb
|
|
455
|
-
- spec/dummy_engine/test/dummy/config/initializers/session_store.rb
|
|
456
|
-
- spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb
|
|
457
|
-
- spec/dummy_engine/test/dummy/config/locales/en.yml
|
|
458
|
-
- spec/dummy_engine/test/dummy/config/routes.rb
|
|
459
|
-
- spec/dummy_engine/test/dummy/config/secrets.yml
|
|
460
|
-
- spec/examples/connection_adapter_examples.rb
|
|
461
|
-
- spec/examples/generic_adapter_custom_configuration_example.rb
|
|
462
|
-
- spec/examples/generic_adapter_examples.rb
|
|
463
|
-
- spec/examples/schema_adapter_examples.rb
|
|
464
|
-
- spec/integration/apartment_rake_integration_spec.rb
|
|
465
|
-
- spec/integration/query_caching_spec.rb
|
|
466
|
-
- spec/integration/use_within_an_engine_spec.rb
|
|
467
|
-
- spec/schemas/v1.rb
|
|
468
|
-
- spec/schemas/v2.rb
|
|
469
|
-
- spec/schemas/v3.rb
|
|
470
|
-
- spec/spec_helper.rb
|
|
471
|
-
- spec/support/apartment_helpers.rb
|
|
472
|
-
- spec/support/capybara_sessions.rb
|
|
473
|
-
- spec/support/config.rb
|
|
474
|
-
- spec/support/contexts.rb
|
|
475
|
-
- spec/support/requirements.rb
|
|
476
|
-
- spec/support/setup.rb
|
|
477
|
-
- spec/tasks/apartment_rake_spec.rb
|
|
478
|
-
- spec/tenant_spec.rb
|
|
479
|
-
- spec/unit/config_spec.rb
|
|
480
|
-
- spec/unit/elevators/domain_spec.rb
|
|
481
|
-
- spec/unit/elevators/first_subdomain_spec.rb
|
|
482
|
-
- spec/unit/elevators/generic_spec.rb
|
|
483
|
-
- spec/unit/elevators/host_hash_spec.rb
|
|
484
|
-
- spec/unit/elevators/host_spec.rb
|
|
485
|
-
- spec/unit/elevators/subdomain_spec.rb
|
|
486
|
-
- spec/unit/migrator_spec.rb
|
|
487
|
-
- spec/unit/reloader_spec.rb
|
|
309
|
+
summary: A Ruby gem for managing database multitenancy. Apartment Gem drop in replacement
|
|
310
|
+
test_files: []
|