database_consistency 1.7.18 → 1.7.19

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: 83e68ed4220ec40c55d0e018d8b99da78f98354b9e550279dba9fda64859e011
4
- data.tar.gz: d729674e108e0051fc41dec2aa92dbe05d645b9b7c0f6fc6f87fb3a61ab2c94e
3
+ metadata.gz: 43676fecc34589198204d39c8f3e1b1a46b6a616fb5c226ee368a009e84cab24
4
+ data.tar.gz: 53980d4481038860da1dd9c673d83b54b4cd5eddd2e98224a0772217dae66d10
5
5
  SHA512:
6
- metadata.gz: a87472873c4cfbfd797742a24229ef01693d610f78db20f15e012779e182bcaf5626743ee85b117bcda95289cf8155cf30a5c13f285b4a68373443a22b2bcc85
7
- data.tar.gz: 8c52b06123f13a5932c3069e6a5cfb609a5008b8622eab6755d04661fd99b3e31482a91b575c760ab6f8f10013364e91eb9d9504df8c2e9b088194de235890d9
6
+ metadata.gz: ff3b416001fee6e744e60ae1a199e74ce7fc4f5e14259cfac8114dab4246d4ca869e545dfe7c3ebee31efc5346c954736fa38606035b7526d7fbe0095aeff152
7
+ data.tar.gz: 8daea1d6b71e9ec2c2a8089a22bce987b1d0e3237cc4d61130cb59fb721d3f0b39b2f8ee094f489ccab5349c6c6ffbf9832be3d40062ade2b03dce7faafd054f
@@ -31,19 +31,24 @@ module DatabaseConsistency
31
31
 
32
32
  def project_models
33
33
  ActiveRecord::Base.descendants.select do |klass|
34
- project_klass?(klass)
34
+ project_klass?(klass) && connected?(klass)
35
35
  end
36
36
  end
37
37
 
38
38
  # Returns list of models to check
39
39
  def models
40
40
  project_models.select do |klass|
41
- !klass.abstract_class? &&
42
- klass.connection.table_exists?(klass.table_name) &&
43
- !klass.name.include?('HABTM_')
41
+ !klass.abstract_class? && !klass.name.include?('HABTM_')
44
42
  end
45
43
  end
46
44
 
45
+ def connected?(klass)
46
+ klass.connection
47
+ rescue ActiveRecord::ConnectionNotEstablished
48
+ puts "#{klass} doesn't have active connection: ignoring"
49
+ false
50
+ end
51
+
47
52
  # Return list of not inherited models
48
53
  def parent_models
49
54
  models.group_by(&:table_name).each_value.flat_map do |models|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '1.7.18'
4
+ VERSION = '1.7.19'
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.18
4
+ version: 1.7.19
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-22 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord