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 +4 -4
- data/lib/rails/sharding/version.rb +1 -1
- data/lib/tasks/rails-sharding.rake +22 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57602c5018eb3d77a8a684949ffab67a73fed32f4a606e7c918f1cef8181e3b5
|
4
|
+
data.tar.gz: bae0f706bbbc0cdc301451630cb781d6f63b39ab23a54fad8ec12d3e9178de25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 134c2e5e7f8967167aef8e923c114b203b39e3ad0799de21d503346ac69b358495e52dec898934b322e2baef977c5bd16a2a989e68471cb0972c90ff3a4b07a4
|
7
|
+
data.tar.gz: 44b6700d349482e1d0fbd8d716299f821edd9fc9750bdffab746a949e0c80732e3747e8864f2594bdc79aa0abe40d73a9894c2712edacd12c33c454797be9235
|
@@ -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
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
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
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
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.
|
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-
|
11
|
+
date: 2019-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|