database_consistency 1.7.6 → 1.7.7

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: 905028bf5f85ba32f99076b621821a83f8b1bbd5b7662ebba0eb84bee85ce5f2
4
- data.tar.gz: 763574e25561f0eebb64922bc2b1ab2841c3bb791b570b2a62a5d0ee56758742
3
+ metadata.gz: f17a39d98d4045434101b952706e15a54da6c1bc8a46860e7daa56932b9569a8
4
+ data.tar.gz: 73a0950925d6158c7e9be1dfa7e9d2c706bed88590884c7ab9784e3434e044e0
5
5
  SHA512:
6
- metadata.gz: a4ca99f196d02deb4286f3468c46e2a724b585f79fce48b8768c206c72ee9cd07da42f930edbfe457ab64083a118810de19bdf7149f617d0cda8dea490f82e65
7
- data.tar.gz: df2c8f4c0d7b4a2e7adf1b6a142f37bcc4b6864d8ae216e33848a5a1adec0723698f841b342080f0a2cefde1e98bd9fd21dfe85bf4721d93500c68bbcb2ba455
6
+ metadata.gz: cd3677888dabe3342854f3ad10e2591cfb79027fd6f210099c4be014f21e02b3317dec9070a35b41876088fbae5bcd5d4faacdb452bbd6e98cfaf7808f3f3294
7
+ data.tar.gz: a1bdfe2c29b6a873bec6f9866eb11b9a2ac90fe4117df6586f9e3ab3687cb20f29f387b23a34b011f5f2c6a52e52ee881b8b3682ee2e527c1673e2249a4f74fa
@@ -38,18 +38,25 @@ module DatabaseConsistency
38
38
  end
39
39
 
40
40
  def check
41
- return analyse(attribute.to_s, type: :null_constraint_missing) if regular_column
41
+ if regular_column
42
+ analyse(attribute.to_s, type: :null_constraint_missing)
43
+ else
44
+ analyse_association
45
+ end
46
+ end
42
47
 
48
+ def analyse_association
43
49
  reports = [analyse(association.foreign_key.to_s, type: :association_missing_null_constraint)]
44
50
  if association.polymorphic?
45
51
  reports << analyse(association.foreign_type.to_s, type: :association_foreign_type_missing_null_constraint)
46
52
  end
47
-
48
- reports
53
+ reports.compact.presence
49
54
  end
50
55
 
51
56
  def analyse(column_name, type:)
52
57
  field = column(column_name)
58
+ # If the column is missing there is nothing we can do.
59
+ return if field.nil?
53
60
 
54
61
  can_be_null = field.null
55
62
  has_weak_option = weak_option?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '1.7.6'
4
+ VERSION = '1.7.7'
5
5
  end
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.6
4
+ version: 1.7.7
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-04-16 00:00:00.000000000 Z
11
+ date: 2023-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord