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 +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/schema_reaper/analyzers/missing_fk_index.rb +10 -0
- data/lib/schema_reaper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c46503b5869a825db2f07b26cb2c8593149d36ec937f4f942ad7429c3bd33c03
|
|
4
|
+
data.tar.gz: 6bc513d41c987266464a1cc66bc34ae50a483ef37daf3751d3051fb34f46d032
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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,
|