Skip to content

Fix FK violation when hard-deleting namespaces with backfills#1924

Merged
shangyian merged 2 commits intoDataJunction:mainfrom
shangyian:hard-del-w-backfills
Mar 25, 2026
Merged

Fix FK violation when hard-deleting namespaces with backfills#1924
shangyian merged 2 commits intoDataJunction:mainfrom
shangyian:hard-del-w-backfills

Conversation

@shangyian
Copy link
Copy Markdown
Collaborator

@shangyian shangyian commented Mar 25, 2026

Summary

DELETE /namespaces/{ns}/hard?cascade=true raised a ForeignKeyViolation when any node in the namespace had materialization backfill records. The bulk SQL delete cascaded through node to noderevision to materialization in the database, but backfill.materialization_id lacked ON DELETE CASCADE, so Postgres blocked the materialization delete.

This PR adds cascade to that FK, along with a migration to apply it to the existing database.

Test Plan

Added a regression test that creates a node w/ materialization w/ backfill and verifies that the namespace hard-delete succeeds.

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

…f the node has materializations and backfills
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 25, 2026

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit 56e1de7
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/69c43c37a049f70009fc52c9

@shangyian shangyian added the bug Something isn't working label Mar 25, 2026
@shangyian shangyian marked this pull request as ready for review March 25, 2026 20:54
@shangyian shangyian merged commit 45171a9 into DataJunction:main Mar 25, 2026
17 checks passed
@shangyian shangyian deleted the hard-del-w-backfills branch March 25, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant