switchman 3.4.0 → 3.4.1

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: be3660461c9c52c63b304de0bb3e5a18e3fe3cdfe7d5f61802b2db2b232f97be
4
- data.tar.gz: 47248f2cb8c6c35396d537e7bd1f938399811d11eb1a07a96778654ccf5dc3f9
3
+ metadata.gz: e080637567925bab42e7d6c87a2963486b16fb5a09eab87ef61fd8056d773ddf
4
+ data.tar.gz: 2694d7353b3cb7df6976aa812897540f1a9fc2188c5a6d2cc15bebfbbabb1371
5
5
  SHA512:
6
- metadata.gz: 60d5b3eb13458b61bbdc8d2a729e10f870284d35fa0694612d793ed8ff9fd15667777dda2e4d28e4fb435a707aff0ca483e51032b396d7496b5d3792e6d6be16
7
- data.tar.gz: fa52c0f4ddf8fea8602917d64f165602ee14ffb9ea72f609a7f9d11e2ac511b5ba3cae9a8ae9915791c268adc0c9f9ef12f142817d0e472bf1c3a17b1f3e262c
6
+ metadata.gz: b3318e8323ebda712ad41873279793ddd5b0d5849a536c9f2dc0fcd3addefb35ff4d364882f27eb59d0c8e27e7c5d79e5c5edc6de66a73024746f79fed23170f
7
+ data.tar.gz: a2d2a1b1682febaffe2856dbdee8eca77241d5781e60fe037677f39c5c77b30d4d4ec5d6b0ff5e8c6cdd947fa79171fc99f0b19ffc3a5a77185bb400069ab537
@@ -171,6 +171,17 @@ module Switchman
171
171
  end
172
172
  end
173
173
 
174
+ def destroy_shadow_records(target_shards: [Shard.current])
175
+ raise Errors::ShadowRecordError, 'Cannot be called on a shadow record.' if shadow_record?
176
+ raise Errors::MethodUnsupportedForUnshardedTableError, 'Cannot be called on a record belonging to an unsharded table.' unless self.class.sharded_column?(self.class.primary_key)
177
+
178
+ Array(target_shards).each do |target_shard|
179
+ next if target_shard == shard
180
+
181
+ target_shard.activate { self.class.where('id = ?', global_id).delete_all }
182
+ end
183
+ end
184
+
174
185
  # Returns "the shard that this record was actually loaded from" , as
175
186
  # opposed to "the shard this record belongs on", which might be
176
187
  # different if this is a shadow record.
@@ -2,14 +2,18 @@
2
2
 
3
3
  module Switchman
4
4
  module Errors
5
- class NonExistentShardError < RuntimeError; end
6
-
7
- class ParallelShardExecError < RuntimeError; end
8
-
9
5
  class ManuallyCreatedShadowRecordError < RuntimeError
10
6
  def initialize(msg = "It looks like you're trying to manually create a shadow record. Please use Switchman::ActiveRecord::Base#save_shadow_record instead.")
11
7
  super
12
8
  end
13
9
  end
10
+
11
+ class NonExistentShardError < RuntimeError; end
12
+
13
+ class ParallelShardExecError < RuntimeError; end
14
+
15
+ class ShadowRecordError < RuntimeError; end
16
+
17
+ class UnshardedTableError < RuntimeError; end
14
18
  end
15
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = '3.4.0'
4
+ VERSION = '3.4.1'
5
5
  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: 3.4.0
4
+ version: 3.4.1
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: 2023-03-31 00:00:00.000000000 Z
13
+ date: 2023-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord