schema_reaper 1.0.7 → 1.0.8

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: 2fc585e50326fe0b90f5ac697eb1211988ebc71e691f8a3253d427d611954adc
4
- data.tar.gz: 84474703f7100d0b0055a3918ec611aa2032cf731ba86f27cb4ab7503a308178
3
+ metadata.gz: c46503b5869a825db2f07b26cb2c8593149d36ec937f4f942ad7429c3bd33c03
4
+ data.tar.gz: 6bc513d41c987266464a1cc66bc34ae50a483ef37daf3751d3051fb34f46d032
5
5
  SHA512:
6
- metadata.gz: 2a54a044eb8d9f910ebef39cd172854101e23ba9e3f67dc91533fa197727bca0de60486cedc35a67e3f92940eabf000bd351f3c7ef27ebd76e4dd0e7689677a0
7
- data.tar.gz: 85e194f2c74030c5df99a703dd523381e40bbfcf6507d37bf4249f42cd48abd0696db0473b6f36f007f61e4894c900b40ffd7c7185e44214589ce3e46f3ea175
6
+ metadata.gz: 6f43c6e3dc588b49d4bdfc2ee0c3baa95d08db6494a0c2f255585c7d1e3521f3db942bfcb1ff0e9197fc46acad98f2ccb14903c6686534bd4562ae8ad9bbb467
7
+ data.tar.gz: 44b21854388bb1fb230c0edc9728c37c5c23137953fa30768425a95257ad15ddb676c582d1e6565d62d77777bab1182c6aa561acc77b6d24839635ded463c1c1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.8] - 2026-09-04
4
+
5
+ ### Fixed
6
+ - `missing_fk_index` no longer advises `add_index` on a foreign-key column
7
+ that is NULL in every row of a non-empty table. Indexing an empty column is
8
+ pointless, and `always_null_column` already flags it for removal; the
9
+ higher-confidence `missing_fk_index` finding was previously winning the
10
+ per-column collapse and producing "add an index to this dead column".
11
+ Found by a clean-room run of 1.0.7 against a live database.
12
+
3
13
  ## [1.0.7] - 2026-09-04
4
14
 
5
15
  Correctness fixes to introspection and analyzers, all contributed by @mitkush
@@ -22,6 +22,7 @@ module SchemaReaper
22
22
  def missing_in(table)
23
23
  fk_columns(table).filter_map do |col|
24
24
  next if indexed?(table, col)
25
+ next if empty_column?(table, col) # never advise indexing a column with no data
25
26
 
26
27
  type_col = polymorphic_type_for(table, col)
27
28
  next if type_col && polymorphic_indexed?(table, type_col, col)
@@ -30,6 +31,15 @@ module SchemaReaper
30
31
  end
31
32
  end
32
33
 
34
+ # A foreign-key column that is NULL in every row of a non-empty table:
35
+ # an index would be pointless, and another analyzer already flags it as
36
+ # dead. Leave that finding to speak for the column.
37
+ def empty_column?(table, col)
38
+ return false unless table.row_count.to_i.positive?
39
+
40
+ table.column(col)&.always_null? || false
41
+ end
42
+
33
43
  def finding_for(table, col, type_col)
34
44
  finding(
35
45
  type: :missing_fk_index,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SchemaReaper
4
- VERSION = "1.0.7"
4
+ VERSION = "1.0.8"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_reaper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - aksshatt