bulk_dependency_eraser 1.4.2 → 1.4.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a505cd8d1072193bb45a5896b9ec1882793c030552ff4a992f06f48b446deca9
|
4
|
+
data.tar.gz: 0061d59c8ccd8abe86eedf0bd78e7fb57f6ed2b14e03fd0ad2c247c136c1ffef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6363cea019a2c86478e3ba5c79c6348db9868c64c40a02a326849827e404bae1542bb3c9686f1ad258717a432c52706b3ce2cbde58e820e520604743c7e7b12
|
7
|
+
data.tar.gz: 1af86850bdacf28110bfa80236ee188c8a5995e92214ee6e4e099696870385f3d62c504031501039747ac4c03cc43b95af7cb24aaae22825c6630e7740c143e4
|
@@ -5,6 +5,28 @@ module BulkDependencyEraser
|
|
5
5
|
# Default Custom Scope for mapped-by-name classes, no effect.
|
6
6
|
DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER = ->(query) { query }
|
7
7
|
|
8
|
+
DEFAULT_DB_READ_WRAPPER = ->(block) {
|
9
|
+
begin
|
10
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
11
|
+
block.call
|
12
|
+
end
|
13
|
+
rescue ActiveRecord::ConnectionNotEstablished
|
14
|
+
# No role: :reading setup, use regular connection
|
15
|
+
block.call
|
16
|
+
end
|
17
|
+
}
|
18
|
+
DEFAULT_DB_WRITE_WRAPPER = ->(block) {
|
19
|
+
begin
|
20
|
+
ActiveRecord::Base.connected_to(role: :writing) do
|
21
|
+
block.call
|
22
|
+
end
|
23
|
+
rescue ActiveRecord::ConnectionNotEstablished
|
24
|
+
# No role: :writing setup, use regular connection
|
25
|
+
block.call
|
26
|
+
end
|
27
|
+
}
|
28
|
+
DEFAULT_DB_BLANK_WRAPPER = ->(block) { block.call }
|
29
|
+
|
8
30
|
DEFAULT_OPTS = {
|
9
31
|
# Applied to all queries. Useful for taking advantage of specific indexes
|
10
32
|
# - not indexed by klass name. Proc would handle the logic for that.
|
@@ -17,10 +39,6 @@ module BulkDependencyEraser
|
|
17
39
|
proc_scopes_per_class_name: {},
|
18
40
|
}.freeze
|
19
41
|
|
20
|
-
|
21
|
-
# Default Database wrapper, no effect.
|
22
|
-
DEFAULT_DB_WRAPPER = ->(block) { block.call }
|
23
|
-
|
24
42
|
attr_reader :errors
|
25
43
|
|
26
44
|
def initialize opts: {}
|
@@ -7,7 +7,7 @@ module BulkDependencyEraser
|
|
7
7
|
# - We would have to instantiate if we wanted to apply that scope filter.
|
8
8
|
instantiate_if_assoc_scope_with_arity: false,
|
9
9
|
# wraps around the DB reading
|
10
|
-
db_read_wrapper: self::
|
10
|
+
db_read_wrapper: self::DEFAULT_DB_READ_WRAPPER,
|
11
11
|
# Will parse these tables and their dependencies, but will remove the tables from the lists after parsing.
|
12
12
|
ignore_tables: [],
|
13
13
|
# Won't parse any table in this list
|
@@ -34,12 +34,6 @@ module BulkDependencyEraser
|
|
34
34
|
reading_proc_scopes_per_class_name: {},
|
35
35
|
}.freeze
|
36
36
|
|
37
|
-
DEFAULT_DB_WRAPPER = ->(block) do
|
38
|
-
ActiveRecord::Base.connected_to(role: :reading) do
|
39
|
-
block.call
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
37
|
DEPENDENCY_NULLIFY = %i[
|
44
38
|
nullify
|
45
39
|
].freeze
|
@@ -2,7 +2,7 @@ module BulkDependencyEraser
|
|
2
2
|
class Deleter < Base
|
3
3
|
DEFAULT_OPTS = {
|
4
4
|
verbose: false,
|
5
|
-
db_delete_wrapper: self::
|
5
|
+
db_delete_wrapper: self::DEFAULT_DB_WRITE_WRAPPER,
|
6
6
|
# Set to true if you want 'ActiveRecord::InvalidForeignKey' errors raised during deletions
|
7
7
|
enable_invalid_foreign_key_detection: false,
|
8
8
|
disable_batching: false,
|
@@ -26,12 +26,6 @@ module BulkDependencyEraser
|
|
26
26
|
deletion_proc_scopes_per_class_name: {},
|
27
27
|
}.freeze
|
28
28
|
|
29
|
-
DEFAULT_DB_WRAPPER = ->(block) do
|
30
|
-
ActiveRecord::Base.connected_to(role: :writing) do
|
31
|
-
block.call
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
29
|
def initialize class_names_and_ids: {}, opts: {}
|
36
30
|
@class_names_and_ids = class_names_and_ids
|
37
31
|
super(opts:)
|
@@ -2,7 +2,7 @@ module BulkDependencyEraser
|
|
2
2
|
class Nullifier < Base
|
3
3
|
DEFAULT_OPTS = {
|
4
4
|
verbose: false,
|
5
|
-
db_nullify_wrapper: self::
|
5
|
+
db_nullify_wrapper: self::DEFAULT_DB_WRITE_WRAPPER,
|
6
6
|
# Set to true if you want 'ActiveRecord::InvalidForeignKey' errors raised during nullifications
|
7
7
|
# - I can't think of a use-case where a nullification would generate an invalid key error
|
8
8
|
# - Not hurting anything to leave it in, but might remove it in the future.
|
@@ -28,12 +28,6 @@ module BulkDependencyEraser
|
|
28
28
|
nullification_proc_scopes_per_class_name: {},
|
29
29
|
}.freeze
|
30
30
|
|
31
|
-
DEFAULT_DB_WRAPPER = ->(block) do
|
32
|
-
ActiveRecord::Base.connected_to(role: :writing) do
|
33
|
-
block.call
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
31
|
# @param class_names_columns_and_ids [Hash] - model names with columns to nullify pointing towards the record IDs that require the nullification.
|
38
32
|
# - structure:
|
39
33
|
# {
|