database_consistency 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fefd921170f4ae51c6f27495defe6d7cfd65f8d4a8bf4e02085aa437ecd2c7a
4
- data.tar.gz: f25b779dbe86f98399e8da406212e2dc421a376af6c8de20dced43d185f62de5
3
+ metadata.gz: 67c90295e24b6b49a4e010a612729f86951d2dda7daba5ac06b091e6b435e040
4
+ data.tar.gz: f1958934302e46a7b21d600a9418bbf58bef2921a5b4d5c2dd5fcccc5a4acda8
5
5
  SHA512:
6
- metadata.gz: 3b7e471c020f59578808c600557a55cc5f86bae0ce0e48ad54880d0eb5844c68a498d0b52fe43e2d7c87dcf236922dfb0dc6b880f5305d32fc81cb5299d14c35
7
- data.tar.gz: 8ec0910740a62dcc7674a70f292e6156686557f0d9e91fc70e0a98af16b045671d054acbe8140cc5922534a044255a51164586f8a7528f7b2740eca48ecc11fa
6
+ metadata.gz: 3bb2a7b1dc68923711cad75c25c2e27a0208ac625a911f61b6e9a6459b5c71640800329f920f14373c4202f100f36b2bf05f2a683772bace47ebc5dd3b3b4ea4
7
+ data.tar.gz: e6a7b06b4bd9d7b3ff002e24c8a320b952c208e864f07ec4f0c255de23b032f14610bf893cc737d3ca2713f1357ee0e0307d91d4a611c48b693e330b1145891e
@@ -24,8 +24,8 @@ module DatabaseConsistency
24
24
  @table_or_model_name ||= model.name.to_s
25
25
  end
26
26
 
27
- def foreign_key_exists? # rubocop:disable Metrics/AbcSize
28
- model.connection.foreign_keys(model.table_name).any? do |foreign_key|
27
+ def foreign_key # rubocop:disable Metrics/AbcSize
28
+ model.connection.foreign_keys(model.table_name).find do |foreign_key|
29
29
  (Helper.extract_columns(association.foreign_key) - Array.wrap(foreign_key.column)).empty? &&
30
30
  foreign_key.to_table == association.klass.table_name
31
31
  end
@@ -43,7 +43,7 @@ module DatabaseConsistency
43
43
  # | persisted | ok |
44
44
  # | missing | fail |
45
45
  def check
46
- if foreign_key_exists?
46
+ if foreign_key
47
47
  report_template(:ok)
48
48
  else
49
49
  report_template(:fail, error_slug: :missing_foreign_key)
@@ -15,7 +15,7 @@ module DatabaseConsistency
15
15
  private
16
16
 
17
17
  def preconditions
18
- association.belongs_to? && foreign_key_exists?
18
+ association.belongs_to? && foreign_key
19
19
  end
20
20
 
21
21
  def check
@@ -34,13 +34,6 @@ module DatabaseConsistency
34
34
  end
35
35
  end
36
36
 
37
- def foreign_key
38
- association.klass
39
- .connection
40
- .foreign_keys(model.table_name)
41
- .find { |fk| fk.column == association.foreign_key.to_s }
42
- end
43
-
44
37
  def cascade?
45
38
  %i[cascade nullify].include? foreign_key.options[:on_delete]
46
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '2.1.2'
4
+ VERSION = '2.1.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_consistency
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-02-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
@@ -136,7 +135,6 @@ dependencies:
136
135
  - - ">"
137
136
  - !ruby/object:Gem::Version
138
137
  version: '1.3'
139
- description:
140
138
  email:
141
139
  - lawliet.djez@gmail.com
142
140
  executables:
@@ -275,9 +273,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
273
  - !ruby/object:Gem::Version
276
274
  version: '0'
277
275
  requirements: []
278
- rubygems_version: 3.2.33
279
- signing_key:
276
+ rubygems_version: 3.7.2
280
277
  specification_version: 4
281
278
  summary: Provide an easy way to check the consistency of the database constraints
282
279
  with the application validations.
283
280
  test_files: []
281
+ ...