switchman 1.9.9 → 1.9.10

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: 09324e1b1e1fcd309435237928b346a70ddb9f8f
4
- data.tar.gz: 22ba223386b76f2db5050e6945bc5d10e08fd214
3
+ metadata.gz: 0c35d2245d3da6dcc3684f329bec545e30a722fc
4
+ data.tar.gz: 0cdf83ae2ff27aa3d2591d99996cce15fd42ef12
5
5
  SHA512:
6
- metadata.gz: bf742c8bc094cc536f8cdfc2893f033d6a476bd51e16e1c556c996f3f0fbc0517ee884b4fef81cbb00e5c5692b45b481eccf6f3b2335fe1a631d224b95db7191
7
- data.tar.gz: 96887f3a05ace152c42682f9c7b2dc64f426ee622d8cb63c8a6db82f5d17b110cbd9a2a260e1a65d53ef2a5bf3bd3fee20b21781705fa9e4bceb9a78284873a9
6
+ metadata.gz: 73897cada38b50274a7c8ba0ee54b52f9fd43e77472ff6ade73dbd7a122c6ffadc06787546cff8b4905549aab08e3c0ccf9607c6c48bc6fd55eb07427874f6c5
7
+ data.tar.gz: cbea8fa73620127f37b97c115c6e25e27856766be69e45659147ebdf4e9fedccb75fd366a4322777a02d90698f9a2445e4139597469ca3de98c419f875abac37
@@ -26,6 +26,7 @@ module Switchman
26
26
  validates_uniqueness_of :default, :if => lambda { |s| s.default? }
27
27
 
28
28
  after_save :clear_cache
29
+ after_destroy :clear_cache
29
30
 
30
31
  scope :primary, -> { where(name: nil).order(:database_server_id, :id).distinct_on(:database_server_id) }
31
32
 
@@ -169,6 +169,12 @@ module Switchman
169
169
  end
170
170
 
171
171
  module CollectionProxy
172
+ def initialize(*args)
173
+ super
174
+ self.shard_value = scope.shard_value
175
+ self.shard_source_value = :association
176
+ end
177
+
172
178
  def shard(*args)
173
179
  scope.shard(*args)
174
180
  end
@@ -9,5 +9,12 @@ module Switchman
9
9
  conn
10
10
  end
11
11
  end
12
+
13
+ module Migrator
14
+ def generate_migrator_advisory_lock_id
15
+ shard_name_hash = Zlib.crc32(Shard.current.name)
16
+ ::ActiveRecord::Migrator::MIGRATOR_SALT * shard_name_hash
17
+ end
18
+ end
12
19
  end
13
20
  end
@@ -156,6 +156,8 @@ module Switchman
156
156
  end
157
157
 
158
158
  def infer_shards_from_primary_key(predicates, binds = nil)
159
+ return unless klass.integral_id?
160
+
159
161
  primary_key = predicates.detect do |predicate|
160
162
  predicate.is_a?(::Arel::Nodes::Binary) && predicate.left.is_a?(::Arel::Attributes::Attribute) &&
161
163
  predicate.left.relation.is_a?(::Arel::Table) && predicate.left.relation.model == klass &&
@@ -111,7 +111,7 @@ module Switchman
111
111
 
112
112
  ::ActiveRecord::Associations::Association.prepend(ActiveRecord::Association)
113
113
  ::ActiveRecord::Associations::BelongsToAssociation.prepend(ActiveRecord::BelongsToAssociation)
114
- ::ActiveRecord::Associations::CollectionProxy.include(ActiveRecord::CollectionProxy)
114
+ ::ActiveRecord::Associations::CollectionProxy.prepend(ActiveRecord::CollectionProxy)
115
115
  if ::Rails.version < '5'
116
116
  ::ActiveRecord::Associations::Builder::CollectionAssociation.include(ActiveRecord::Builder::CollectionAssociation)
117
117
  end
@@ -129,6 +129,7 @@ module Switchman
129
129
 
130
130
  ::ActiveRecord::LogSubscriber.prepend(ActiveRecord::LogSubscriber)
131
131
  ::ActiveRecord::Migration.prepend(ActiveRecord::Migration)
132
+ ::ActiveRecord::Migrator.prepend(ActiveRecord::Migrator)
132
133
 
133
134
  ::ActiveRecord::Reflection::AbstractReflection.include(ActiveRecord::Reflection::AbstractReflection)
134
135
  ::ActiveRecord::Reflection::AssociationReflection.prepend(ActiveRecord::Reflection::AssociationScopeCache)
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.9.9"
2
+ VERSION = "1.9.10"
3
3
  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: 1.9.9
4
+ version: 1.9.10
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: 2017-04-17 00:00:00.000000000 Z
13
+ date: 2017-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -177,7 +177,6 @@ files:
177
177
  - db/migrate/20130328212039_create_switchman_shards.rb
178
178
  - db/migrate/20130328224244_create_default_shard.rb
179
179
  - db/migrate/20161206323434_add_back_default_string_limits_switchman.rb
180
- - db/shard_1708.sqlite3
181
180
  - lib/switchman.rb
182
181
  - lib/switchman/action_controller/caching.rb
183
182
  - lib/switchman/active_record/abstract_adapter.rb
@@ -244,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
243
  version: '0'
245
244
  requirements: []
246
245
  rubyforge_project:
247
- rubygems_version: 2.5.1
246
+ rubygems_version: 2.6.11
248
247
  signing_key:
249
248
  specification_version: 4
250
249
  summary: Rails 4 sharding magic
File without changes