fix: drop the model's outbound foreign keys too (#632) - #793
Merged
axellpadilla merged 2 commits intoAug 1, 2026
Merged
Conversation
This was referenced Aug 1, 2026
drop_fk_constraints() only matched foreign keys whose referenced table was the model, so the keys the table itself declares survived the macro and kept blocking a truncate or rebuild of the table they point at. Join on parent_object_id as well, still scoped to the model's own schema. Consolidate the module's tests into a single project and dbt invocation, adding fk_model to cover both directions. No CHANGELOG change, so this cherry-picks clean onto release/v1.11.
axellpadilla
force-pushed
the
fix/632-drop-outbound-fk-constraints
branch
from
August 1, 2026 19:11
9ed4283 to
9aad31f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
drop_fk_constraints()only matched foreign keys whose referenced table was the model, so the keys the table itself declares survived the macro and kept blocking a truncate or rebuild of the table they point at. The join now also matchesparent_object_id, still scoped to the model's own schema so same-named tables elsewhere are untouched.PR #774 already added the schema filter that issue #632 also asked for; this is the remaining half.
Tests:
test_index_macros.pyis consolidated into one project and one dbt invocation (was 3 projects / 6 invocations). Newfk_modelcarries a foreign key in each direction and asserts both are gone; verified it fails on the unfixed macro. The index-creation assertion is now scoped to its own tables so a drop-macro bug can't fail it too.Stacked on #792 — retarget to master once that merges. Backport: #794
Closes #632