Skip to content

fix(tables): log row writes to the change log instead of locking the table definition row - #8765

Merged
TheodoreSpeaks merged 3 commits into
stagingfrom
fix/table-row-change-triggers
Oct 8, 2026
Merged

TheodoreSpeaks merged 3 commits into
stagingfrom
fix/table-row-change-triggers

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

Type of Change

  • Bug fix

Testing

  • New row-writes.integration.ts case: a second session holds the definition row FOR NO KEY UPDATE (what a commit stuck in SyncRep holds) while insert, batch insert, upsert, update by id, update by filter, delete by filter, and replace each run. All seven commit (56 ms total) and live count = COUNT(*). Against the pre-change triggers the first insert fails at the 3 s lock timeout
  • The cascade-delete foreign-key bug was caught by the TTL suite's fixture cleanup before the guard was added
  • Table suites + TTL cleanup on a migrated DB: 148 passed; push-provisioned: 117 passed (migration-only cases skip as before). rows_version and TTL helpers now read stored + tail
  • bun run lint, check:audits, check:migrations origin/staging, block-registry check, docs-manifest:check, drizzle generate clean, 1,011 table unit tests; root bun run test green except one desktop terminal test that passes in isolation

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

https://claude.ai/code/session_01CJxC2fgucGVpT59RV5Z7xv

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Oct 8, 2026 10:03pm UTC

Request Review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

We detected this is a high-risk PR and are running a free ultrareview. An ultrareview is a deeper, multi-pass review that catches hard-to-find bugs a standard review can miss. We'll post the findings when it completes.

This PR appears to change a database schema or migrate data, where a missed bug can corrupt or lose records, so a deeper multi-pass review is worth running.

Want an ultrareview on every high-risk PR? Set up automated ultrareviews.

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical impact] The PR appears safe to merge with the stated deployment prerequisites.

Summary

Row writes now append count changes and version bumps to user_table_row_changes instead of updating the shared definition row.

  • Migration 0401 swaps the trigger functions together and removes the old insert/delete version triggers.
  • The development script locks the change log before reconciling stored counts with real rows.
  • The held-definition test now covers both insert-side and existing-row upserts.
  • Both previous review concerns are addressed. No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  W["Row write"] --> T["Row triggers"]
  T --> L["user_table_row_changes"]
  L --> F["Fold job"]
  F --> D["user_table_definitions"]
  L --> R["Read stored values plus pending changes"]
  D --> R
Loading

Reviews (3) · Last reviewed commit: "fix(tables): lock the change log before ..." · Reviewed by Greptile

Comment thread packages/db/scripts/apply-dev-table-triggers.ts Outdated
Comment thread apps/sim/lib/table/rows/row-writes.integration.ts

@cubic-dev-ai cubic-dev-ai Bot 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.

We detected this is a high-risk PR and ran a free ultrareview. An ultrareview is a deeper, multi-pass review that catches hard-to-find bugs a standard review can miss.

This PR appears to change a database schema or migrate data, where a missed bug can corrupt or lose records, so a deeper multi-pass review is worth running.

Want an ultrareview on every high-risk PR? Set up automated ultrareviews.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread packages/db/scripts/apply-dev-table-triggers.ts Outdated
Comment thread apps/sim/lib/table/rows/row-writes.integration.ts Outdated
Comment thread apps/sim/lib/table/rows/row-writes.integration.ts Outdated
Comment thread apps/sim/lib/table/rows/row-writes.integration.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@TheodoreSpeaks
TheodoreSpeaks force-pushed the fix/table-row-change-triggers branch from 8eabf8a to e79bbff Compare October 8, 2026 21:57
@TheodoreSpeaks
TheodoreSpeaks merged commit 1bb9e86 into staging Oct 8, 2026
46 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the fix/table-row-change-triggers branch October 8, 2026 22:09

This branch was successfully deployed

1 active deployment
Preview — e79bbffc Deployed Oct 8, 2026 by vercel[bot]
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.

1 participant