switchman 3.3.5 → 3.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b02846fe7319e31d24a50618d5b2f7120109e09c4a4dc40125a25f7299207bf0
4
- data.tar.gz: bd42f42242e7f0b8cc88ca76206625607ad00e33d58247ac6bd9d090f7c3722a
3
+ metadata.gz: a0e25e9a338b74ed4340f605d27978bba42bd45ef47ddac2bf7c44047db8a014
4
+ data.tar.gz: a6f6cdb8f1686213391d38f1eb172fefa9346012f3ce055b152696f1dcd05975
5
5
  SHA512:
6
- metadata.gz: 4109620cb05413f9ebfc56290e74e73d94682439a62cd1813b93ffb2b28aff2ec84aafb5bb888a283e418c8fcbe743b384bc09d3cd18f2d5008920e2707d491f
7
- data.tar.gz: c5ce42651aed4080935281b4a131d56517bf84dc78c2dc38f0ce3ec6db62387b0848120392eb2187e8f86a2b61557c0a1ad34e1482cbed2f9b3f4cfbf90bfd22
6
+ metadata.gz: fe38ed259e6d881d9f60ecd0dd96b65a3dd154b750beb3b5ee5b8af03e7683f056238feb464fc32c5156841b439200c6ff0c9bf5959dc108b5bb91c298bd450a
7
+ data.tar.gz: b74decf8b11511749f80ffc792b2a98dbf6cdf36670d1f2db84a80975138aee8f0f4c11dab8883b9be93413324fb7f574589d6788781cd8e664dea34fe964cbd
@@ -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.5'
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.5
4
+ version: 3.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer