Refactor/Fix missing foreign key index detection + missing FK constraints heuristics and update tests #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Missing FK indices Algorithm
==> I went from 67 missing foreign keys ( with false positives ) to over 200 in my production application 💀. I checked manually and indeed, it turns out I have a LOT of missing indices. Which for me indicates that the
DetectFkColumnwas a bit weird ... EDIT: indeed the root cause was that cases such asuser_account_idwere returninguserinstead ofuser_account!missing Fk constraints check heuristics algorithm
Enhance missing foreign key detection (
missing_fk_constraints) logic and update testspolymorphic associationsAdd ignore list to missing_fk_constraint check
IgnoreListclass which can be later be used in other checks if needed. As input it takes an ignore list, then can determine if a column in a table is ignored based on the ignore list.Enhance and Fix foreign key column detection logic
FkDetectColumnclass to improve detection of foreign key columns, accommodating underscored prefixes and mixed-case names, such asuser_account_idrelated to pawurb/rails-pg-extras#58