switchman 3.3.4 → 3.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dfbc3eb712e4dabeaf71e1772014d3fcc50f439d7266c03943050e4054791f2
4
- data.tar.gz: 902b59d7077cab4e9c583b55e5f1c3e4df6565e678b806f7df4515033031ea65
3
+ metadata.gz: a0e25e9a338b74ed4340f605d27978bba42bd45ef47ddac2bf7c44047db8a014
4
+ data.tar.gz: a6f6cdb8f1686213391d38f1eb172fefa9346012f3ce055b152696f1dcd05975
5
5
  SHA512:
6
- metadata.gz: cba1cdfe3b5297443fe62064db702a3164fab8939497196e2c325e3a28fb6c4d1bbbd64698dd7c861c7f60b32eb5d91d6c1273ec4f8d3eafe45f675f5fcc36b1
7
- data.tar.gz: b66c46f377262622339d18bd5167c6fca048b02e8167f9636aefae642afca1987ec51c71ed68a4fb3177fd0176c589b4f587c3336cc863f4b3478ed25503af53
6
+ metadata.gz: fe38ed259e6d881d9f60ecd0dd96b65a3dd154b750beb3b5ee5b8af03e7683f056238feb464fc32c5156841b439200c6ff0c9bf5959dc108b5bb91c298bd450a
7
+ data.tar.gz: b74decf8b11511749f80ffc792b2a98dbf6cdf36670d1f2db84a80975138aee8f0f4c11dab8883b9be93413324fb7f574589d6788781cd8e664dea34fe964cbd
@@ -12,8 +12,10 @@ module Switchman
12
12
 
13
13
  # rubocop:disable Naming/AccessorMethodName override method
14
14
  def set_schema_cache(cache)
15
+ schema_cache = get_schema_cache(cache.connection)
16
+
15
17
  cache.instance_variables.each do |x|
16
- self.schema_cache.instance_variable_set(x, cache.instance_variable_get(x))
18
+ schema_cache.instance_variable_set(x, cache.instance_variable_get(x))
17
19
  end
18
20
  end
19
21
  # rubocop:enable Naming/AccessorMethodName override method
@@ -221,12 +221,12 @@ module Switchman
221
221
 
222
222
  unless schema == false
223
223
  shard.activate do
224
- reset_column_information
225
-
226
- ::ActiveRecord::Base.connection.transaction(requires_new: true) do
227
- ::ActiveRecord::Base.connection.migration_context.migrate
224
+ with_empty_caches do
225
+ ::ActiveRecord::Base.connection.transaction(requires_new: true) do
226
+ ::ActiveRecord::Base.connection.migration_context.migrate
227
+ end
228
228
  end
229
- reset_column_information
229
+
230
230
  ::ActiveRecord::Base.descendants.reject do |m|
231
231
  m <= UnshardedRecord || !m.table_exists?
232
232
  end.each(&:define_attribute_methods)
@@ -278,5 +278,20 @@ module Switchman
278
278
  def reset_column_information
279
279
  ::ActiveRecord::Base.descendants.reject { |m| m <= UnshardedRecord }.each(&:reset_column_information)
280
280
  end
281
+
282
+ def with_empty_caches
283
+ connection = ::ActiveRecord::Base.connection
284
+ connection_pool = ::ActiveRecord::Base.connection_pool
285
+ previous_schema_cache = connection_pool.get_schema_cache(connection)
286
+ temporary_schema_cache = ::ActiveRecord::ConnectionAdapters::SchemaCache.new(connection)
287
+
288
+ reset_column_information
289
+ connection_pool.set_schema_cache(temporary_schema_cache)
290
+
291
+ yield
292
+
293
+ connection_pool.set_schema_cache(previous_schema_cache)
294
+ reset_column_information
295
+ end
281
296
  end
282
297
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = '3.3.4'
4
+ VERSION = '3.3.6'
5
5
  end
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: 3.3.4
4
+ version: 3.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer