Skip to content

feat(tables): trigger workflows on row deletes - #7161

Open
j15z wants to merge 3 commits into
refactor/consolidate-timezone-mathfrom
feat/table-trigger-row-deletes
Open

feat(tables): trigger workflows on row deletes#7161
j15z wants to merge 3 commits into
refactor/consolidate-timezone-mathfrom
feat/table-trigger-row-deletes

Conversation

@j15z

@j15z j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Table triggers can now start workflows when rows are deleted and receive each deleted row's final values. Delete events are dispatched only after committed single-row, ID-based, filtered, background, and Expiration-cleanup deletions.

This is PR 4 of 4 in the row-expiration stack. It builds on PR #7072 and completes the integration by making automatic Expiration deletions observable through the same Table trigger as manual deletions.

PostgreSQL returns each deleted { id, data } snapshot as part of the DELETE, avoiding a racy pre-delete read. Large deletes dispatch byte-bounded snapshot batches after each transaction commits, and trigger matching requires the table's canonical workspace. Dispatch remains best-effort, so a workflow failure cannot roll back a committed deletion. Payloads expose final values through row, rawRow, and previousRow, with no changed columns.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Focused coverage exercises trigger configuration and payloads, single and bulk deletes, post-commit ordering, bounded background batches, workspace isolation, and Expiration cleanup.
  • At the restacked stack tip, 29 focused test files pass with 453 tests.
  • bun run type-check, bun run lint:check, bun run check:api-validation, and bun run check:migrations origin/staging pass.
  • Review focus: every dispatch path must use rows returned by the committed delete, never a pre-delete read that could become stale.

Checklist

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

Screenshots/Videos

No screenshots captured. Trigger configuration tests cover the new Row Deleted option and its payload contract.

Post-Deploy Monitoring & Validation

  • Logs: Search the TableTrigger logger for Firing delete events and Error in fireTableTrigger.
  • Healthy: Each committed deletion produces the expected workflow execution in the same workspace, with bounded trigger batches and no increase in delete latency or memory pressure.
  • Failure: Missing or duplicate executions, cross-workspace matching, repeated trigger errors, or elevated delete-worker memory/latency.
  • Mitigation: Disable affected Row Deleted workflows or roll back this PR; committed deletions remain valid because trigger delivery is post-commit and best-effort.
  • Window and owner: Monitor for 24 hours after deployment; owner is the Tables feature owner.

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 29, 2026 9:39pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds post-commit Row Deleted workflow dispatch using snapshots returned by committed deletes.

  • Supports single-row, ID-based, filtered, background, and TTL-cleanup deletion paths.
  • Adds byte-bounded snapshot batching and exposes deleted values through the trigger payload.
  • Adds the Row Deleted trigger option and focused coverage for dispatch and payload behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/table/rows/ordering.ts Returns committed deletion snapshots in bounded batches and invokes post-commit handlers.
apps/sim/lib/table/rows/service.ts Dispatches deletion triggers for explicit single-row, ID-based, and filtered delete operations.
apps/sim/lib/table/delete-runner.ts Connects committed background-delete batches to trigger dispatch using the revalidated table definition.
apps/sim/background/cleanup-table-row-ttl.ts Returns TTL-deleted row snapshots and dispatches them after each locked transaction commits.
apps/sim/lib/table/trigger.ts Adds delete-event payload handling with the deleted snapshot exposed as the previous row.
apps/sim/triggers/table/poller.ts Exposes Row Deleted as a configurable table-trigger event.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant Delete as Delete transaction
  participant Trigger as Table trigger dispatcher
  participant Workflow
  Caller->>Delete: Delete matching rows
  Delete-->>Caller: Commit and return row snapshots
  Caller->>Trigger: Dispatch Row Deleted snapshots
  Trigger-->>Workflow: Queue matching workflow runs
Loading

Reviews (2): Last reviewed commit: "fix(tables): bound delete trigger snapsh..." | Re-trigger Greptile

Comment thread apps/sim/lib/table/rows/service.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files

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

Re-trigger cubic

Comment thread apps/sim/lib/table/delete-runner.ts Outdated
Comment thread apps/sim/lib/table/rows/ordering.ts Outdated
Comment thread apps/sim/lib/table/rows/service.ts Outdated
@j15z

j15z commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z
j15z force-pushed the feat/table-trigger-row-deletes branch from eb3e201 to bd53d8e Compare August 28, 2026 22:20
@j15z
j15z force-pushed the feat/table-trigger-row-deletes branch from bd53d8e to f5df1cb Compare August 28, 2026 22:57
@j15z
j15z force-pushed the feat/table-trigger-row-deletes branch from f5df1cb to 36ee470 Compare August 29, 2026 21:21
@j15z
j15z force-pushed the feat/table-trigger-row-deletes branch from 36ee470 to 203811b Compare August 29, 2026 21:30
@j15z
j15z force-pushed the feat/table-trigger-row-deletes branch from 203811b to f3bbe0b Compare August 29, 2026 21:38
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