rails-sharding 1.1.1 → 1.1.2

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: 0a9130c4b0e150421dfa3655dcb44f5638cbca380851ec171cd1a85fa24752d8
4
- data.tar.gz: 78086e09183f55c0e7fd6524447894d7b81d3e846bded97a10beeae3fb23cc0a
3
+ metadata.gz: 57602c5018eb3d77a8a684949ffab67a73fed32f4a606e7c918f1cef8181e3b5
4
+ data.tar.gz: bae0f706bbbc0cdc301451630cb781d6f63b39ab23a54fad8ec12d3e9178de25
5
5
  SHA512:
6
- metadata.gz: cfdf3372608f63b68a500ec4522191d30d378fb35c1d386ef525c9f74f5281f64f7c694719b85b20d7359101d11aa69640b6d5b6e2c90ad07ff7e18f5935035f
7
- data.tar.gz: 27af314dc9d9475801688ca28aae49ad5ed691d8dec71bc1a96f783ad1c72ec23565c094a404931610521de61f21846d33fb7fa37932e2c86d5a954b8c62f6c0
6
+ metadata.gz: 134c2e5e7f8967167aef8e923c114b203b39e3ad0799de21d503346ac69b358495e52dec898934b322e2baef977c5bd16a2a989e68471cb0972c90ff3a4b07a4
7
+ data.tar.gz: 44b6700d349482e1d0fbd8d716299f821edd9fc9750bdffab746a949e0c80732e3747e8864f2594bdc79aa0abe40d73a9894c2712edacd12c33c454797be9235
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Sharding
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -274,29 +274,31 @@ shards_namespace = namespace :shards do
274
274
 
275
275
  desc "Empty the test shards (drops all tables) (options: SHARD_GROUP=x, SHARD=x)"
276
276
  task :purge => [:_make_activerecord_base_shardable] do
277
- Rails::Sharding.for_each_shard(ENV["SHARD_GROUP"], ENV["SHARD"]) do |shard_group, shard, configuration|
278
- puts "== Purging test shard #{shard_group}:#{shard}"
279
- begin
280
- # establishes connection with test shard, saving if it was connected before (rails 4.2 doesn't do this, but should)
281
- should_reconnect = Rails::Sharding::ConnectionHandler.connection_pool(shard_group, shard).active_connection?
282
- Rails::Sharding::ConnectionHandler.establish_connection(shard_group, shard, 'test')
277
+ begin
278
+ # saves the current RAILS_ENV (we must change it so the environment is set correcly on the metadata table)
279
+ initial_rails_env = Rails.env
280
+ Rails.env = 'test'
283
281
 
284
- # saves the current RAILS_ENV (we must change it so the environment is set correcly on the metadata table)
285
- initial_rails_env = Rails.env
286
- Rails.env = 'test'
287
-
288
- Rails::Sharding.using_shard(shard_group, shard) do
289
- ActiveRecord::Tasks::DatabaseTasks.purge(configuration)
290
- end
291
- ensure
292
- # restores rails env
293
- Rails.env = initial_rails_env
294
-
295
- if should_reconnect
296
- # reestablishes connection for RAILS_ENV environment (whatever that is)
297
- Rails::Sharding::ConnectionHandler.establish_connection(shard_group, shard)
282
+ Rails::Sharding.for_each_shard(ENV["SHARD_GROUP"], ENV["SHARD"]) do |shard_group, shard, configuration|
283
+ puts "== Purging test shard #{shard_group}:#{shard}"
284
+ begin
285
+ # establishes connection with test shard, saving if it was connected before (rails 4.2 doesn't do this, but should)
286
+ should_reconnect = Rails::Sharding::ConnectionHandler.connection_pool(shard_group, shard).active_connection?
287
+ Rails::Sharding::ConnectionHandler.establish_connection(shard_group, shard, 'test')
288
+
289
+ Rails::Sharding.using_shard(shard_group, shard) do
290
+ ActiveRecord::Tasks::DatabaseTasks.purge(configuration)
291
+ end
292
+ ensure
293
+ if should_reconnect
294
+ # reestablishes connection for RAILS_ENV environment (whatever that is)
295
+ Rails::Sharding::ConnectionHandler.establish_connection(shard_group, shard)
296
+ end
298
297
  end
299
298
  end
299
+ ensure
300
+ # restores rails env
301
+ Rails.env = initial_rails_env
300
302
  end
301
303
  end
302
304
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-sharding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique Gubert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-07 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails