database_consistency 1.7.24 → 1.7.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/database_consistency/configuration.rb +4 -0
- data/lib/database_consistency/helper.rb +10 -6
- data/lib/database_consistency/processors/associations_processor.rb +1 -3
- data/lib/database_consistency/processors/base_processor.rb +0 -5
- data/lib/database_consistency/processors/columns_processor.rb +1 -3
- data/lib/database_consistency/processors/enums_processor.rb +1 -3
- data/lib/database_consistency/processors/indexes_processor.rb +1 -3
- data/lib/database_consistency/processors/models_processor.rb +1 -3
- data/lib/database_consistency/processors/validators_fractions_processor.rb +1 -3
- data/lib/database_consistency/processors/validators_processor.rb +1 -3
- data/lib/database_consistency/version.rb +1 -1
- data/lib/database_consistency/writers/autofix/helpers/migration.rb +2 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f10f22151f5ddbb4c219ebb0efbb2af17e6d73bbd0153ad861cb748c6d202829
|
4
|
+
data.tar.gz: be376924b1db3b17b61eeb8cd0154f855c4b9b1a458cfacaae70c7019c1707ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dde326fd325136cd5972b9d89886cd6f3a39cddda39091ba6ece85f2261f50a9c71d2efdd0ed20c634c974d0604e21fb7b8f28130444d8f237bcdc6ea046a8e
|
7
|
+
data.tar.gz: 69e0304fb9b2aad06cd3efc4a152dd5b51f616f29e3dab9c8252e717393b724de84a8a051ca50700a417954ba96fcead5b2fa121bdd50dfada88c91d0ee96d27
|
@@ -48,6 +48,10 @@ module DatabaseConsistency
|
|
48
48
|
value
|
49
49
|
end
|
50
50
|
|
51
|
+
def model_enabled?(model)
|
52
|
+
database_enabled?(Helper.database_name(model)) && enabled?(model.name.to_s)
|
53
|
+
end
|
54
|
+
|
51
55
|
def database_enabled?(name)
|
52
56
|
value = configuration.dig('DatabaseConsistencyDatabases', name, 'enabled')
|
53
57
|
|
@@ -29,17 +29,19 @@ module DatabaseConsistency
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def project_models
|
32
|
+
def project_models(configuration)
|
33
33
|
ActiveRecord::Base.descendants.select do |klass|
|
34
|
+
next unless configuration.model_enabled?(klass)
|
35
|
+
|
34
36
|
project_klass?(klass) && connected?(klass)
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
# Returns list of models to check
|
39
|
-
def models
|
40
|
-
project_models.select do |klass|
|
41
|
+
def models(configuration)
|
42
|
+
project_models(configuration).select do |klass|
|
41
43
|
!klass.abstract_class? &&
|
42
|
-
klass.
|
44
|
+
klass.table_exists? &&
|
43
45
|
!klass.name.include?('HABTM_')
|
44
46
|
end
|
45
47
|
end
|
@@ -52,8 +54,8 @@ module DatabaseConsistency
|
|
52
54
|
end
|
53
55
|
|
54
56
|
# Return list of not inherited models
|
55
|
-
def parent_models
|
56
|
-
models.group_by(&:table_name).each_value.flat_map do |models|
|
57
|
+
def parent_models(configuration)
|
58
|
+
models(configuration).group_by(&:table_name).each_value.flat_map do |models|
|
57
59
|
models.reject { |model| models.include?(model.superclass) }
|
58
60
|
end
|
59
61
|
end
|
@@ -65,6 +67,8 @@ module DatabaseConsistency
|
|
65
67
|
return true unless Module.respond_to?(:const_source_location) && defined?(Bundler)
|
66
68
|
|
67
69
|
!Module.const_source_location(klass.to_s).first.to_s.include?(Bundler.bundle_path.to_s)
|
70
|
+
rescue NameError
|
71
|
+
false
|
68
72
|
end
|
69
73
|
|
70
74
|
# @return [Boolean]
|
@@ -15,10 +15,8 @@ module DatabaseConsistency
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def check # rubocop:disable Metrics/MethodLength
|
18
|
-
Helper.models.flat_map do |model|
|
18
|
+
Helper.models(configuration).flat_map do |model|
|
19
19
|
DebugContext.with(model: model.name) do
|
20
|
-
next unless model_enabled?(model)
|
21
|
-
|
22
20
|
Helper.first_level_associations(model).flat_map do |association|
|
23
21
|
DebugContext.with(association: association.name) do
|
24
22
|
enabled_checkers.flat_map do |checker_class|
|
@@ -16,10 +16,8 @@ module DatabaseConsistency
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def check # rubocop:disable Metrics/MethodLength
|
19
|
-
Helper.parent_models.flat_map do |model|
|
19
|
+
Helper.parent_models(configuration).flat_map do |model|
|
20
20
|
DebugContext.with(model: model.name) do
|
21
|
-
next unless model_enabled?(model)
|
22
|
-
|
23
21
|
model.columns.flat_map do |column|
|
24
22
|
DebugContext.with(column: column.name) do
|
25
23
|
enabled_checkers.flat_map do |checker_class|
|
@@ -11,10 +11,8 @@ module DatabaseConsistency
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def check # rubocop:disable Metrics/MethodLength
|
14
|
-
Helper.models.flat_map do |model|
|
14
|
+
Helper.models(configuration).flat_map do |model|
|
15
15
|
DebugContext.with(model: model.name) do
|
16
|
-
next unless model_enabled?(model)
|
17
|
-
|
18
16
|
model.defined_enums.keys.flat_map do |enum|
|
19
17
|
DebugContext.with(enum: enum) do
|
20
18
|
enabled_checkers.flat_map do |checker_class|
|
@@ -13,10 +13,8 @@ module DatabaseConsistency
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def check # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
16
|
-
Helper.parent_models.flat_map do |model|
|
16
|
+
Helper.parent_models(configuration).flat_map do |model|
|
17
17
|
DebugContext.with(model: model.name) do
|
18
|
-
next unless model_enabled?(model)
|
19
|
-
|
20
18
|
indexes = model.connection.indexes(model.table_name)
|
21
19
|
|
22
20
|
indexes.flat_map do |index|
|
@@ -11,10 +11,8 @@ module DatabaseConsistency
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def check
|
14
|
-
Helper.project_models.flat_map do |model|
|
14
|
+
Helper.project_models(configuration).flat_map do |model|
|
15
15
|
DebugContext.with(model: model.name) do
|
16
|
-
next unless model_enabled?(model)
|
17
|
-
|
18
16
|
enabled_checkers.flat_map do |checker_class|
|
19
17
|
DebugContext.with(checker: checker_class) do
|
20
18
|
checker = checker_class.new(model)
|
@@ -12,10 +12,8 @@ module DatabaseConsistency
|
|
12
12
|
|
13
13
|
# @return [Array<Hash>]
|
14
14
|
def check # rubocop:disable Metrics/MethodLength
|
15
|
-
Helper.parent_models.flat_map do |model|
|
15
|
+
Helper.parent_models(configuration).flat_map do |model|
|
16
16
|
DebugContext.with(model: model.name) do
|
17
|
-
next unless model_enabled?(model)
|
18
|
-
|
19
17
|
model._validators.flat_map do |attribute, validators|
|
20
18
|
DebugContext.with(attribute: attribute) do
|
21
19
|
next unless attribute
|
@@ -13,10 +13,8 @@ module DatabaseConsistency
|
|
13
13
|
|
14
14
|
# @return [Array<Hash>]
|
15
15
|
def check # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
16
|
-
Helper.parent_models.flat_map do |model|
|
16
|
+
Helper.parent_models(configuration).flat_map do |model|
|
17
17
|
DebugContext.with(model: model.name) do
|
18
|
-
next unless model_enabled?(model)
|
19
|
-
|
20
18
|
model.validators.flat_map do |validator|
|
21
19
|
next unless validator.respond_to?(:attributes)
|
22
20
|
|
@@ -6,10 +6,9 @@ module DatabaseConsistency
|
|
6
6
|
module Helpers
|
7
7
|
module Migration # :nodoc:
|
8
8
|
def migration_path(name)
|
9
|
-
|
10
|
-
schema_migration = ActiveRecord::Base.connection.schema_migration
|
9
|
+
migration_context = ActiveRecord::Base.connection.migration_context
|
11
10
|
|
12
|
-
last =
|
11
|
+
last = migration_context.migrations.last
|
13
12
|
version = ActiveRecord::Migration.next_migration_number(last&.version.to_i + 1)
|
14
13
|
|
15
14
|
"db/migrate/#{version}_#{name.underscore}.rb"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_consistency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -126,14 +126,14 @@ dependencies:
|
|
126
126
|
name: sqlite3
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - ">"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '1.3'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - ">"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1.3'
|
139
139
|
description:
|