active_record_shards 3.11.5 → 3.12.0.beta1

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: 3d357ad8613bcbea31498900f8e1d97b5d21bfc1b8259372268e456bdaad77a2
4
- data.tar.gz: 1c0d9c52923910fbacb3c94549174db6681fbd9f5184ba455f300341fa204142
3
+ metadata.gz: 3b58db094b64e706872768e27a2c92827d182f5cde938b974de333ad99c911e2
4
+ data.tar.gz: c6bd4169b99f66409c0bf8576e79bd34f567ed92e88c00abcfd4d8ce9a9d3f02
5
5
  SHA512:
6
- metadata.gz: d8c1b2faa6c40c7f447d32a72240958d4098bc95b52150083009d38d65fd1e99488d77604eba4ae4b8d26bbd61ff9ddf264391aacec5b466e53dc1f79f33e523
7
- data.tar.gz: c68d21caf7452690ed7107e7ee7f2650d33f6facc794396249e3ad9e14a75f1cb0a936b6bfb0f2e75b3082ca7ad57d172a139052f72a6de2e098e60405831b9e
6
+ metadata.gz: bbe1f3c052a2594c13c817e7fb06894b38582f4bde8656347eace28217ac349f689e4326fd3f5c941bf7075db3232c038b7ae47effdc80d0778a5304d978ae78
7
+ data.tar.gz: b2fae9dd53cf66ec159a2d67eec9d65432b47dcee687111295839755e3e69c05c5f40f2805cc47ed37096479004b7d59e9c3c6b5eb5d6c7d0217363a7ebdd29d
@@ -100,7 +100,10 @@ module ActiveRecordShards
100
100
 
101
101
  module ActiveRelationPatches
102
102
  def self.included(base)
103
- [:calculate, :exists?, :pluck, :find_with_associations].each do |m|
103
+ [
104
+ :calculate, :exists?, :pluck,
105
+ ActiveRecord::VERSION::MAJOR >= 4 ? :load : :find_with_associations
106
+ ].each do |m|
104
107
  ActiveRecordShards::DefaultSlavePatches.wrap_method_in_on_slave(false, base, m)
105
108
  end
106
109
  end
@@ -1,25 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveRecord
3
3
  class Migrator
4
- class << self
5
- [:up, :down, :run].each do |m|
6
- define_method("#{m}_with_sharding") do |*args|
7
- ActiveRecord::Base.on_shard(nil) do
8
- send("#{m}_without_sharding", *args)
9
- end
10
- ActiveRecord::Base.on_all_shards do
11
- send("#{m}_without_sharding", *args)
12
- end
13
- end
14
- alias_method :"#{m}_without_sharding", m.to_sym
15
- alias_method m.to_sym, :"#{m}_with_sharding"
4
+ def self.shards_migration_context
5
+ if ActiveRecord::VERSION::STRING >= '5.2.0'
6
+ ActiveRecord::MigrationContext.new(['db/migrate'])
7
+ else
8
+ self
16
9
  end
17
10
  end
18
11
 
12
+ def run_with_sharding
13
+ ActiveRecord::Base.on_shard(nil) { run_without_sharding }
14
+ ActiveRecord::Base.on_all_shards { run_without_sharding }
15
+ end
16
+ alias_method :run_without_sharding, :run
17
+ alias_method :run, :run_with_sharding
18
+
19
+ def migrate_with_sharding
20
+ ActiveRecord::Base.on_shard(nil) { migrate_without_sharding }
21
+ ActiveRecord::Base.on_all_shards { migrate_without_sharding }
22
+ end
23
+ alias_method :migrate_without_sharding, :migrate
24
+ alias_method :migrate, :migrate_with_sharding
25
+
19
26
  # don't allow Migrator class to cache versions
20
27
  undef migrated
21
28
  def migrated
22
- self.class.get_all_versions
29
+ self.class.shards_migration_context.get_all_versions
23
30
  end
24
31
 
25
32
  # list of pending migrations is any migrations that haven't run on all shards.
@@ -38,7 +45,7 @@ module ActiveRecord
38
45
  missing = {}
39
46
 
40
47
  collect = lambda do |shard|
41
- migrated = get_all_versions
48
+ migrated = shards_migration_context.get_all_versions
42
49
 
43
50
  p = versions - migrated
44
51
  pending[shard] = p if p.any?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.5
4
+ version: 3.12.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-05-24 00:00:00.000000000 Z
13
+ date: 2018-06-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.2.16
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '5.2'
24
+ version: '6.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,7 +31,7 @@ dependencies:
31
31
  version: 3.2.16
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '5.2'
34
+ version: '6.0'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: activesupport
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -41,7 +41,7 @@ dependencies:
41
41
  version: 3.2.16
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
- version: '5.2'
44
+ version: '6.0'
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  version: 3.2.16
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.2'
54
+ version: '6.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: wwtd
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -224,9 +224,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
224
  version: '2.0'
225
225
  required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ">="
227
+ - - ">"
228
228
  - !ruby/object:Gem::Version
229
- version: '0'
229
+ version: 1.3.1
230
230
  requirements: []
231
231
  rubyforge_project:
232
232
  rubygems_version: 2.7.6