switchman 1.14.0 → 1.15.0

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.
@@ -121,7 +121,7 @@ module Switchman
121
121
  klass.before do
122
122
  raise "Sharding did not set up correctly" if @@sharding_failed
123
123
  Shard.clear_cache
124
- if ::Rails.version >= '5.1' ? use_transactional_tests : (use_transactional_tests || use_transactional_fixtures)
124
+ if use_transactional_tests
125
125
  Shard.default(true)
126
126
  @shard1 = Shard.find(@shard1.id)
127
127
  @shard2 = Shard.find(@shard2.id)
@@ -137,7 +137,7 @@ module Switchman
137
137
 
138
138
  klass.after do
139
139
  next if @@sharding_failed
140
- if ::Rails.version >= '5.1' ? use_transactional_tests : (use_transactional_tests || use_transactional_fixtures)
140
+ if use_transactional_tests
141
141
  shards = [@shard2]
142
142
  shards << @shard1 unless @shard1.database_server == Shard.default.database_server
143
143
  shards.each do |shard|
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.14.0"
2
+ VERSION = "1.15.0"
3
3
  end
@@ -20,7 +20,12 @@ module Switchman
20
20
  open = servers.delete('open')
21
21
 
22
22
  servers = servers.map { |server| DatabaseServer.find(server) }.compact
23
- servers.concat(DatabaseServer.all.select { |server| server.config[:open] }) if open
23
+ if open
24
+ open_servers = DatabaseServer.all.select { |server| server.config[:open] }
25
+ servers.concat(open_servers)
26
+ servers << DatabaseServer.find(nil) if open_servers.empty?
27
+ servers.uniq!
28
+ end
24
29
  servers = DatabaseServer.all - servers if negative
25
30
  end
26
31
 
@@ -67,7 +72,17 @@ module Switchman
67
72
  shard = Shard.current
68
73
  puts "#{shard.id}: #{shard.description}"
69
74
  ::ActiveRecord::Base.connection_pool.spec.config[:shard_name] = Shard.current.name
70
- ::ActiveRecord::Base.configurations[::Rails.env] = ::ActiveRecord::Base.connection_pool.spec.config.stringify_keys
75
+ if ::Rails.version < '6.0'
76
+ ::ActiveRecord::Base.configurations[::Rails.env] = ::ActiveRecord::Base.connection_pool.spec.config.stringify_keys
77
+ else
78
+ # Adopted from the deprecated code that currently lives in rails proper
79
+ remaining_configs = ::ActiveRecord::Base.configurations.configurations.reject { |db_config| db_config.env_name == ::Rails.env }
80
+ new_config = ::ActiveRecord::DatabaseConfigurations.new(::Rails.env =>
81
+ ::ActiveRecord::Base.connection_pool.spec.config.stringify_keys).configurations
82
+ new_configs = remaining_configs + new_config
83
+
84
+ ::ActiveRecord::Base.configurations = new_configs
85
+ end
71
86
  shard.database_server.unshackle do
72
87
  old_actions.each { |action| action.call(*task_args) }
73
88
  end
@@ -195,9 +210,7 @@ module Switchman
195
210
  @filter_database_servers_chain ||= ->(servers) { servers }
196
211
  end
197
212
  end
198
- end
199
213
 
200
- module Switchman
201
214
  module ActiveRecord
202
215
  module PostgreSQLDatabaseTasks
203
216
  def structure_dump(filename, extra_flags=nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-06-12 00:00:00.000000000 Z
13
+ date: 2020-05-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '5.0'
21
+ version: '5.1'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
24
  version: '6.1'
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: '5.0'
31
+ version: '5.1'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '6.1'
@@ -38,7 +38,7 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '5.0'
41
+ version: '5.1'
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
44
  version: '6.1'
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: '5.0'
51
+ version: '5.1'
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '6.1'
@@ -173,7 +173,6 @@ extra_rdoc_files: []
173
173
  files:
174
174
  - Rakefile
175
175
  - app/models/switchman/shard.rb
176
- - app/models/switchman/shard_internal.rb
177
176
  - db/migrate/20130328212039_create_switchman_shards.rb
178
177
  - db/migrate/20130328224244_create_default_shard.rb
179
178
  - db/migrate/20161206323434_add_back_default_string_limits_switchman.rb