database_consistency 1.7.12 → 1.7.14
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/checkers/association_checkers/foreign_key_checker.rb +2 -0
- data/lib/database_consistency/checkers/association_checkers/foreign_key_type_checker.rb +2 -1
- data/lib/database_consistency/checkers/association_checkers/missing_association_class_checker.rb +36 -0
- data/lib/database_consistency/processors/associations_processor.rb +2 -1
- data/lib/database_consistency/version.rb +1 -1
- data/lib/database_consistency/writers/simple/missing_association_class.rb +27 -0
- data/lib/database_consistency/writers/simple_writer.rb +7 -6
- data/lib/database_consistency.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aae1ecf43d2307f2006fecf4ba08a40e69565bb240ce8d7c59d2d271ec11ee0
|
4
|
+
data.tar.gz: f59e8e3422196f502c6aefe81c8995c01b2167ad7f158d57ceabb787cd2f46e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cac4e844ed502055658862456132ea245cb5208bfd5d1a184c50097086f7ab469020aa00bf55b64ae9ff056eb69ce222ff3175150950829f0ad1ea8c7f99acb7
|
7
|
+
data.tar.gz: 0a5768efcffc548bd35feba6a6b8f22fd11ee1ae795db9aeb7664422a3bfbd88aef34f1216433be874b7be5fc2a2e4eb367a66048b95a56256922b21ac8ae551
|
@@ -25,7 +25,8 @@ module DatabaseConsistency
|
|
25
25
|
!association.polymorphic? &&
|
26
26
|
association.through_reflection.nil? &&
|
27
27
|
association.klass.present? &&
|
28
|
-
association.macro != :has_and_belongs_to_many
|
28
|
+
association.macro != :has_and_belongs_to_many &&
|
29
|
+
association.klass.table_exists?
|
29
30
|
rescue NameError
|
30
31
|
false
|
31
32
|
end
|
data/lib/database_consistency/checkers/association_checkers/missing_association_class_checker.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DatabaseConsistency
|
4
|
+
module Checkers
|
5
|
+
# This class checks if an association has existing class defined
|
6
|
+
class MissingAssociationClassChecker < AssociationChecker
|
7
|
+
Report = ReportBuilder.define(
|
8
|
+
DatabaseConsistency::Report,
|
9
|
+
:class_name
|
10
|
+
)
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def preconditions
|
15
|
+
!association.polymorphic?
|
16
|
+
end
|
17
|
+
|
18
|
+
def check
|
19
|
+
association.klass
|
20
|
+
report_template(:ok)
|
21
|
+
rescue NameError
|
22
|
+
report_template(:fail, error_slug: :missing_association_class)
|
23
|
+
end
|
24
|
+
|
25
|
+
def report_template(status, error_slug: nil)
|
26
|
+
Report.new(
|
27
|
+
status: status,
|
28
|
+
error_message: nil,
|
29
|
+
error_slug: error_slug,
|
30
|
+
class_name: association.class_name,
|
31
|
+
**report_attributes
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -8,7 +8,8 @@ module DatabaseConsistency
|
|
8
8
|
Checkers::MissingIndexChecker,
|
9
9
|
Checkers::ForeignKeyChecker,
|
10
10
|
Checkers::ForeignKeyTypeChecker,
|
11
|
-
Checkers::ForeignKeyCascadeChecker
|
11
|
+
Checkers::ForeignKeyCascadeChecker,
|
12
|
+
Checkers::MissingAssociationClassChecker
|
12
13
|
].freeze
|
13
14
|
|
14
15
|
private
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DatabaseConsistency
|
4
|
+
module Writers
|
5
|
+
module Simple
|
6
|
+
class MissingAssociationClass < Base # :nodoc:
|
7
|
+
private
|
8
|
+
|
9
|
+
def template
|
10
|
+
'refers to undefined model "%<class_name>s"'
|
11
|
+
end
|
12
|
+
|
13
|
+
def unique_attributes
|
14
|
+
{
|
15
|
+
class_name: report.class_name
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def attributes
|
20
|
+
{
|
21
|
+
class_name: report.class_name
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -6,29 +6,30 @@ module DatabaseConsistency
|
|
6
6
|
# The simplest formatter
|
7
7
|
class SimpleWriter < BaseWriter
|
8
8
|
SLUG_TO_WRITER = {
|
9
|
+
association_foreign_type_missing_null_constraint: Simple::AssociationForeignTypeMissingNullConstraint,
|
9
10
|
association_missing_index: Simple::AssociationMissingIndex,
|
10
11
|
association_missing_null_constraint: Simple::AssociationMissingNullConstraint,
|
11
|
-
|
12
|
+
enum_values_inconsistent_with_ar_enum: Simple::EnumValuesInconsistentWithArEnum,
|
13
|
+
enum_values_inconsistent_with_inclusion: Simple::EnumValuesInconsistentWithInclusion,
|
12
14
|
has_one_missing_unique_index: Simple::HasOneMissingUniqueIndex,
|
15
|
+
inconsistent_enum_type: Simple::InconsistentEnumType,
|
13
16
|
inconsistent_types: Simple::InconsistentTypes,
|
14
17
|
length_validator_greater_limit: Simple::LengthValidatorGreaterLimit,
|
15
18
|
length_validator_lower_limit: Simple::LengthValidatorLowerLimit,
|
16
19
|
length_validator_missing: Simple::LengthValidatorMissing,
|
20
|
+
missing_association_class: Simple::MissingAssociationClass,
|
17
21
|
missing_foreign_key: Simple::MissingForeignKey,
|
22
|
+
missing_foreign_key_cascade: Simple::MissingForeignKeyCascade,
|
18
23
|
missing_unique_index: Simple::MissingUniqueIndex,
|
19
24
|
missing_uniqueness_validation: Simple::MissingUniquenessValidation,
|
20
25
|
null_constraint_association_misses_validator: Simple::NullConstraintAssociationMissesValidator,
|
21
26
|
null_constraint_misses_validator: Simple::NullConstraintMissesValidator,
|
22
27
|
null_constraint_missing: Simple::NullConstraintMissing,
|
23
28
|
possible_null: Simple::PossibleNull,
|
29
|
+
redundant_case_insensitive_option: Simple::RedundantCaseInsensitiveOption,
|
24
30
|
redundant_index: Simple::RedundantIndex,
|
25
31
|
redundant_unique_index: Simple::RedundantUniqueIndex,
|
26
32
|
small_primary_key: Simple::SmallPrimaryKey,
|
27
|
-
inconsistent_enum_type: Simple::InconsistentEnumType,
|
28
|
-
missing_foreign_key_cascade: Simple::MissingForeignKeyCascade,
|
29
|
-
enum_values_inconsistent_with_ar_enum: Simple::EnumValuesInconsistentWithArEnum,
|
30
|
-
enum_values_inconsistent_with_inclusion: Simple::EnumValuesInconsistentWithInclusion,
|
31
|
-
redundant_case_insensitive_option: Simple::RedundantCaseInsensitiveOption,
|
32
33
|
three_state_boolean: Simple::ThreeStateBoolean
|
33
34
|
}.freeze
|
34
35
|
|
data/lib/database_consistency.rb
CHANGED
@@ -39,6 +39,7 @@ require 'database_consistency/writers/simple/enum_values_inconsistent_with_ar_en
|
|
39
39
|
require 'database_consistency/writers/simple/enum_values_inconsistent_with_inclusion'
|
40
40
|
require 'database_consistency/writers/simple/redundant_case_insensitive_option'
|
41
41
|
require 'database_consistency/writers/simple/three_state_boolean'
|
42
|
+
require 'database_consistency/writers/simple/missing_association_class'
|
42
43
|
require 'database_consistency/writers/simple_writer'
|
43
44
|
|
44
45
|
require 'database_consistency/writers/autofix/helpers/migration'
|
@@ -66,6 +67,7 @@ require 'database_consistency/checkers/association_checkers/missing_index_checke
|
|
66
67
|
require 'database_consistency/checkers/association_checkers/foreign_key_checker'
|
67
68
|
require 'database_consistency/checkers/association_checkers/foreign_key_type_checker'
|
68
69
|
require 'database_consistency/checkers/association_checkers/foreign_key_cascade_checker'
|
70
|
+
require 'database_consistency/checkers/association_checkers/missing_association_class_checker'
|
69
71
|
|
70
72
|
require 'database_consistency/checkers/column_checkers/column_checker'
|
71
73
|
require 'database_consistency/checkers/column_checkers/null_constraint_checker'
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/database_consistency/checkers/association_checkers/foreign_key_cascade_checker.rb
|
151
151
|
- lib/database_consistency/checkers/association_checkers/foreign_key_checker.rb
|
152
152
|
- lib/database_consistency/checkers/association_checkers/foreign_key_type_checker.rb
|
153
|
+
- lib/database_consistency/checkers/association_checkers/missing_association_class_checker.rb
|
153
154
|
- lib/database_consistency/checkers/association_checkers/missing_index_checker.rb
|
154
155
|
- lib/database_consistency/checkers/base_checker.rb
|
155
156
|
- lib/database_consistency/checkers/column_checkers/column_checker.rb
|
@@ -217,6 +218,7 @@ files:
|
|
217
218
|
- lib/database_consistency/writers/simple/length_validator_greater_limit.rb
|
218
219
|
- lib/database_consistency/writers/simple/length_validator_lower_limit.rb
|
219
220
|
- lib/database_consistency/writers/simple/length_validator_missing.rb
|
221
|
+
- lib/database_consistency/writers/simple/missing_association_class.rb
|
220
222
|
- lib/database_consistency/writers/simple/missing_foreign_key.rb
|
221
223
|
- lib/database_consistency/writers/simple/missing_foreign_key_cascade.rb
|
222
224
|
- lib/database_consistency/writers/simple/missing_unique_index.rb
|
@@ -264,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
266
|
- !ruby/object:Gem::Version
|
265
267
|
version: '0'
|
266
268
|
requirements: []
|
267
|
-
rubygems_version: 3.
|
269
|
+
rubygems_version: 3.2.33
|
268
270
|
signing_key:
|
269
271
|
specification_version: 4
|
270
272
|
summary: Provide an easy way to check the consistency of the database constraints
|