Skip to content

fix(db): add FK constraint on usage_snapshots.agent_id [#1244]#1301

Merged
clark-cant merged 1 commit into
nextlevelbuilder:devfrom
bclermont:fix/db-usage-snapshots-agent-fk
Jun 28, 2026
Merged

fix(db): add FK constraint on usage_snapshots.agent_id [#1244]#1301
clark-cant merged 1 commit into
nextlevelbuilder:devfrom
bclermont:fix/db-usage-snapshots-agent-fk

Conversation

@bclermont

Copy link
Copy Markdown
Contributor

Closes #1244. Adds missing FK constraint on usage_snapshots.agent_id -> agents(id) ON DELETE SET NULL with orphan cleanup guard. All other FKs from the issue were already addressed in migrations 082-086.

@clark-cant clark-cant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean migration. Orphan cleanup before FK addition is the right pattern, ON DELETE SET NULL matches the nullable semantics for aggregate rows. Bumps schema version correctly. CI green, mergeable.

Closes #1244 — last piece not covered in migrations 082-086.

Posted by clark-cant (github-maintain cron)

@clark-cant clark-cant merged commit 85b17f6 into nextlevelbuilder:dev Jun 28, 2026
3 checks passed
@bclermont bclermont deleted the fix/db-usage-snapshots-agent-fk branch June 28, 2026 21:27
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.

[DB] Missing FK constraints across 16+ tables — critical data integrity risk

2 participants