Skip to content

fix: drop the model's outbound foreign keys too (#632) - #793

Merged
axellpadilla merged 2 commits into
fix/catalog-lock-contentionfrom
fix/632-drop-outbound-fk-constraints
Aug 1, 2026
Merged

fix: drop the model's outbound foreign keys too (#632)#793
axellpadilla merged 2 commits into
fix/catalog-lock-contentionfrom
fix/632-drop-outbound-fk-constraints

Conversation

@axellpadilla

@axellpadilla axellpadilla commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

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 matches parent_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.py is consolidated into one project and one dbt invocation (was 3 projects / 6 invocations). New fk_model carries 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

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
axellpadilla force-pushed the fix/632-drop-outbound-fk-constraints branch from 9ed4283 to 9aad31f Compare August 1, 2026 19:11
@axellpadilla
axellpadilla merged commit aa87efd into master Aug 1, 2026
37 checks passed
@axellpadilla
axellpadilla deleted the fix/632-drop-outbound-fk-constraints branch August 1, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Macro drop_fk_constraints() only drops incoming FKs, ignoring outgoing FKs

1 participant