switchman 1.5.21 → 1.6.0

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
  SHA1:
3
- metadata.gz: a6c8d63c04c23a59c2cda990cbed599098887d5e
4
- data.tar.gz: 421b3c6dad49777eb5b032d82a579bc0a2802d89
3
+ metadata.gz: 5216239c0a0c3b84a975c7f5a7c63250a36c3960
4
+ data.tar.gz: 9eff38ae0cdfe742c47d25667dfa9bd5f807ad44
5
5
  SHA512:
6
- metadata.gz: d428c6d5e5af925e71f8517c99ec3346a769360082114b8e3590c3459e9e104b7db6431ec41f5703d87fb9dc8b43ce64b51ac59629c0365a3afe6701a26b5aff
7
- data.tar.gz: 24c0021a45980b354394c1c3f3138bf54bb7a236c18f903bb83143cb34c3b16527c55823e4fd24ca608c588d88562256d3840167ad82636b686b60b8744d0f3b
6
+ metadata.gz: 1a8afa7d5bbedf8bf89d797cab7eab0285a36d01d7f1efada6fb6e7aabb459ee44abfb3f82bc9e043399cf943a95bb1bee6b2f932ea92e65b97d77d7c2510801
7
+ data.tar.gz: fa08be1de119479e4e9a0ad3ac6f5c6a6a18f8c3400d2d784bf30be78aaff3665875eafb2a621bd2e3a4f6181affe95a49a74b6d73e55244c0810c7409b318da
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.5.21"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -44,7 +44,11 @@ module Switchman
44
44
  { parallel: ENV['PARALLEL'].to_i, max_procs: ENV['MAX_PARALLEL_PROCS'] }
45
45
  end
46
46
 
47
- def self.shardify_task(task_name)
47
+ # categories - an array or proc, to activate as the current shard during the
48
+ # task. tasks which modify the schema may want to pass all categories in
49
+ # so that schema updates for non-default tables happen against all shards.
50
+ # this is handled automatically for the default migration tasks, below.
51
+ def self.shardify_task(task_name, categories: [:default])
48
52
  old_task = ::Rake::Task[task_name]
49
53
  old_actions = old_task.actions.dup
50
54
  old_task.actions.clear
@@ -57,7 +61,8 @@ module Switchman
57
61
 
58
62
  ::Shackles.activate(:deploy) do
59
63
  begin
60
- Shard.with_each_shard(scope, Shard.categories, options) do
64
+ categories = categories.call if categories.respond_to?(:call)
65
+ Shard.with_each_shard(scope, categories, options) do
61
66
  shard = Shard.current
62
67
  puts "#{shard.id}: #{shard.description}"
63
68
  ::ActiveRecord::Base.connection_pool.spec.config[:shard_name] = Shard.current.name
@@ -75,7 +80,9 @@ module Switchman
75
80
  end
76
81
  end
77
82
 
78
- %w{db:migrate db:migrate:up db:migrate:down db:rollback}.each { |task_name| shardify_task(task_name) }
83
+ %w{db:migrate db:migrate:up db:migrate:down db:rollback}.each do |task_name|
84
+ shardify_task(task_name, categories: ->{ Shard.categories })
85
+ end
79
86
 
80
87
  private
81
88
 
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.5.21
4
+ version: 1.6.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: 2016-09-09 00:00:00.000000000 Z
13
+ date: 2016-09-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  version: '0'
227
227
  requirements: []
228
228
  rubyforge_project:
229
- rubygems_version: 2.6.4
229
+ rubygems_version: 2.4.5.1
230
230
  signing_key:
231
231
  specification_version: 4
232
232
  summary: Rails 4 sharding magic