ros-apartment 2.8.1 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/Appraisals +15 -3
- data/gemfiles/rails_6_1.gemfile +23 -0
- data/lib/apartment.rb +16 -1
- data/lib/apartment/tasks/task_helper.rb +12 -0
- data/lib/apartment/version.rb +1 -1
- data/lib/tasks/apartment.rake +1 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f31fef7b2332c76bce3bff4823754c145b7a049bbf845ce29bb22b65b29585e4
|
4
|
+
data.tar.gz: 657b9a8bf128f912894e03bd2331b2e2201bf9f43f38515117e434ef65694341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d35580a7ed02ea8423251e0e7ed555d002fe34f4d2705cb16b982e5211a5f79fd8f078b97c7ac633f8b1bb605c9ada8176a6c082c0d1ad00591ba4b079acb7b4
|
7
|
+
data.tar.gz: fa77558d5731e0a99c8ff1f8611c5353e633a5bbcd37fe94c64fe310414f8f724177d6fa7121ca88031315638990087546892a7411fd7477e37362de52682e31
|
data/.circleci/config.yml
CHANGED
@@ -70,7 +70,7 @@ workflows:
|
|
70
70
|
matrix:
|
71
71
|
parameters:
|
72
72
|
ruby_version: ["ruby:2.6-buster", "ruby:2.7-buster"]
|
73
|
-
gemfile: ["gemfiles/rails_5_2.gemfile", "gemfiles/rails_6_0.gemfile"]
|
73
|
+
gemfile: ["gemfiles/rails_5_2.gemfile", "gemfiles/rails_6_0.gemfile", "gemfiles/rails_6_1.gemfile"]
|
74
74
|
|
75
75
|
rubocop:
|
76
76
|
jobs:
|
data/Appraisals
CHANGED
@@ -45,14 +45,26 @@ appraise 'rails-6-0' do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
appraise 'rails-6-1' do
|
49
|
+
gem 'rails', '~> 6.1.0'
|
50
|
+
platforms :ruby do
|
51
|
+
gem 'sqlite3', '~> 1.4'
|
52
|
+
end
|
53
|
+
platforms :jruby do
|
54
|
+
gem 'activerecord-jdbc-adapter', '~> 61.0'
|
55
|
+
gem 'activerecord-jdbcpostgresql-adapter', '~> 61.0'
|
56
|
+
gem 'activerecord-jdbcmysql-adapter', '~> 61.0'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
48
60
|
appraise 'rails-master' do
|
49
61
|
gem 'rails', git: 'https://github.com/rails/rails.git'
|
50
62
|
platforms :ruby do
|
51
63
|
gem 'sqlite3', '~> 1.4'
|
52
64
|
end
|
53
65
|
platforms :jruby do
|
54
|
-
gem 'activerecord-jdbc-adapter', '~>
|
55
|
-
gem 'activerecord-jdbcpostgresql-adapter', '~>
|
56
|
-
gem 'activerecord-jdbcmysql-adapter', '~>
|
66
|
+
gem 'activerecord-jdbc-adapter', '~> 61.0'
|
67
|
+
gem 'activerecord-jdbcpostgresql-adapter', '~> 61.0'
|
68
|
+
gem 'activerecord-jdbcmysql-adapter', '~> 61.0'
|
57
69
|
end
|
58
70
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
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
|
+
|
13
|
+
platforms :ruby do
|
14
|
+
gem "sqlite3", "~> 1.4"
|
15
|
+
end
|
16
|
+
|
17
|
+
platforms :jruby do
|
18
|
+
gem "activerecord-jdbc-adapter", "~> 61.0"
|
19
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
|
20
|
+
gem "activerecord-jdbcmysql-adapter", "~> 61.0"
|
21
|
+
end
|
22
|
+
|
23
|
+
gemspec path: "../"
|
data/lib/apartment.rb
CHANGED
@@ -27,7 +27,7 @@ module Apartment
|
|
27
27
|
|
28
28
|
WRITER_METHODS = %i[tenant_names database_schema_file excluded_models
|
29
29
|
persistent_schemas connection_class
|
30
|
-
db_migrate_tenants seed_data_file
|
30
|
+
db_migrate_tenants db_migrate_tenant_missing_strategy seed_data_file
|
31
31
|
parallel_migration_threads pg_excluded_names].freeze
|
32
32
|
|
33
33
|
attr_accessor(*ACCESSOR_METHODS)
|
@@ -72,6 +72,21 @@ module Apartment
|
|
72
72
|
@db_migrate_tenants = true
|
73
73
|
end
|
74
74
|
|
75
|
+
# How to handle tenant missing on db:migrate
|
76
|
+
# defaults to :rescue_exception
|
77
|
+
# available options: rescue_exception, raise_exception, create_tenant
|
78
|
+
def db_migrate_tenant_missing_strategy
|
79
|
+
valid = %i[rescue_exception raise_exception create_tenant]
|
80
|
+
value = @db_migrate_tenant_missing_strategy || :rescue_exception
|
81
|
+
|
82
|
+
return value if valid.include?(value)
|
83
|
+
|
84
|
+
key_name = 'config.db_migrate_tenant_missing_strategy'
|
85
|
+
opt_names = valid.join(', ')
|
86
|
+
|
87
|
+
raise ApartmentError, "Option #{value} not valid for `#{key_name}`. Use one of #{opt_names}"
|
88
|
+
end
|
89
|
+
|
75
90
|
# Default to empty array
|
76
91
|
def excluded_models
|
77
92
|
@excluded_models || []
|
@@ -36,5 +36,17 @@ module Apartment
|
|
36
36
|
rescue Apartment::TenantExists => e
|
37
37
|
puts "Tried to create already existing tenant: #{e}"
|
38
38
|
end
|
39
|
+
|
40
|
+
def self.migrate_tenant(tenant_name)
|
41
|
+
strategy = Apartment.db_migrate_tenant_missing_strategy
|
42
|
+
create_tenant(tenant_name) if strategy == :create_tenant
|
43
|
+
|
44
|
+
puts("Migrating #{tenant_name} tenant")
|
45
|
+
Apartment::Migrator.migrate tenant_name
|
46
|
+
rescue Apartment::TenantNotFound => e
|
47
|
+
raise e if strategy == :raise_exception
|
48
|
+
|
49
|
+
puts e.message
|
50
|
+
end
|
39
51
|
end
|
40
52
|
end
|
data/lib/apartment/version.rb
CHANGED
data/lib/tasks/apartment.rake
CHANGED
@@ -30,13 +30,7 @@ apartment_namespace = namespace :apartment do
|
|
30
30
|
task :migrate do
|
31
31
|
Apartment::TaskHelper.warn_if_tenants_empty
|
32
32
|
Apartment::TaskHelper.each_tenant do |tenant|
|
33
|
-
|
34
|
-
Apartment::TaskHelper.create_tenant(tenant)
|
35
|
-
puts("Migrating #{tenant} tenant")
|
36
|
-
Apartment::Migrator.migrate tenant
|
37
|
-
rescue Apartment::TenantNotFound => e
|
38
|
-
puts e.message
|
39
|
-
end
|
33
|
+
Apartment::TaskHelper.migrate_tenant(tenant)
|
40
34
|
end
|
41
35
|
end
|
42
36
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ros-apartment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brunner
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -251,6 +251,7 @@ files:
|
|
251
251
|
- gemfiles/rails_5_1.gemfile
|
252
252
|
- gemfiles/rails_5_2.gemfile
|
253
253
|
- gemfiles/rails_6_0.gemfile
|
254
|
+
- gemfiles/rails_6_1.gemfile
|
254
255
|
- gemfiles/rails_master.gemfile
|
255
256
|
- lib/apartment.rb
|
256
257
|
- lib/apartment/active_record/connection_handling.rb
|