Repository navigation
feat(automations): Drop the legacy Automation tables - #2184
Merged
Merged
Conversation
Drop junior_scheduler_tasks, junior_event_tasks, junior_scheduler_runs, and junior_task_executions. No deployed code reads or writes them since #2183. Also drop the scheduler creator trigger function, which the table drop leaves behind. Remove junior_automation_versions.kind and the junior_conversations origin_* columns from the schema, so new code stops writing them. Drizzle names every schema column in each insert, so old workers still write them during the deploy. Migration 0057 keeps them in the database, and a follow-up migration drops them. The heartbeat now links the Conversation when it settles an event automation run. Refs #2176
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dcramer
approved these changes
Oct 18, 2026
dcramer
marked this pull request as ready for review
October 18, 2026 08:20
dcramer
added a commit
that referenced
this pull request
Oct 18, 2026
Follow-up cleanup after the Automation table migrations (#2179, #2183, #2184). ## Bug The heartbeat settled Scheduled automation runs only for automations that were not deleted. It did this through `listIncompleteScheduledRuns` → `listScheduledAutomations`, which filters `status <> 'deleted'`. Delete marks only *pending* runs as skipped. So when an automation was deleted while its run was dispatched, the run stayed `running` forever and never became an execution. Event runs already settle in this case. `listIncompleteScheduledRuns` now reads `junior_automation_runs` joined to `kind = 'scheduled'`, with no status filter. One function now covers both the heartbeat and the per-automation claim check. This also stops the heartbeat from loading and decoding every Scheduled automation on each tick. The new heartbeat integration case fails on `main` (the run stays `running`) and passes with this change. ## Dead code - `scheduled-automations/personal.ts`: removed `listViewerScheduledAutomations` and its cursor code. `collection.ts` replaced it, and it had no callers. - Removed `scheduledAutomationPrincipalLabel` and `ScheduledAutomationCredentialMode`, which had no callers. - Removed the `scheduled-automations/index.ts` and `tools.ts` barrels. Their two consumers now import the tool files directly, as AGENTS.md asks. - Removed the "adopts deployed Scheduler rows" component test. It builds the dropped legacy tables to test migration SQL, which the testing policy rules out. - Removed the `kind` tie-breaker from the Automation collection order. Ids are unique in one table, so it never decided anything. - Removed README notes about older workers during rolling deploys. ## Not in this PR These change behavior or contracts, so they need their own PRs: - `executionActor` is written and never read. The schema is `.strict()` and stored rows contain the field, so removing it needs a data migration first. - Ownership uses two rules: `creator_identity_id` for scheduled rows, `team_id + creator_slack_user_id` for event rows. - Remove `kind` from `/api/automations/:kind/:id` and the dashboard `/automations/:kind/:id/...` URLs. Both already have it today; ids are unique, so the routes can key on id alone. - Two locking schemes: an advisory lock for scheduled rows, `FOR UPDATE` for event rows. - Run writes are split across `execution-stats.ts` and the two `runs.ts` files. `recordAutomationExecution` also swallows write errors. - Migration 0058, which drops `junior_automation_versions.kind` and `junior_conversations.origin_*`. ## Checks - `pnpm typecheck` passed. - `pnpm lint` passed. It includes the file-length, migration-metadata and test-architecture checks. - `vitest`: `heartbeat`, `scheduled-automations-sql`, `api/automations` and `api/automation-edits` all pass. - `slack-schedule-tools` and `event-automations`: everything passes with `--testTimeout=30000`, except "delivers the current automation card and retains its reference in web history". That test fails the same way on `main` in my sandbox. At the default 5s timeout, unrelated tests in these files time out in my sandbox on `main` too. <!-- junior-request-attribution:start --> via **David Cramer**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1792312176.174969 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1792312176.174969) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1792312176.174969/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
This was referenced Nov 9, 2026
dcramer
added a commit
that referenced
this pull request
Nov 11, 2026
Migration 0057 kept `junior_automation_versions.kind`, the `junior_conversations` `origin_type`/`origin_id`/`origin_run_id` columns, and `junior_conversations_origin_idx` for one release. Its comment said 0058 drops them, but no migration did. #2184 already removed them from the snapshot, and no runtime code reads them. Migration 0101 drops them with `IF EXISTS`, and the schema test no longer filters them out. #2959 stopped writing the `awaiting_resume` Conversation status in 0.288.0. Workers before that release could still write it after 0089 ran, so 0101 repeats the 0089 rename to `paused`, and `executionStatusFromValue` no longer accepts the old name. The `awaiting_resume` agent-dispatch outcome is a different contract and does not change. A deployment that upgrades straight from before 0057 would have old workers writing the origin columns during its rollout. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A3321086e7c3262ca03ac3d37c3e087c3 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A3321086e7c3262ca03ac3d37c3e087c3) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A3321086e7c3262ca03ac3d37c3e087c3/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 3 of #2176. Drops the four Automation tables that #2179 and #2183 replaced. Stops writing the old columns, and leaves the column drops to a small follow-up.
Dropped in migration 0057
junior_scheduler_tasks,junior_event_tasks,junior_scheduler_runs,junior_task_executions, with their schema files and exports.junior_scheduler_assign_creator_identity()function from migration 0016. Dropping the table drops its trigger but not the function.On main since #2183, only the schema files name these tables. No code reads or writes them, so old workers are safe while the migration runs.
Removed from the schema, dropped in a follow-up
junior_automation_versions.kindjunior_conversations.origin_type,origin_id,origin_run_id, andjunior_conversations_origin_idxMain still writes these columns. Drizzle names every schema column in each insert, using
DEFAULTwhen the code gives no value. SorecordAutomationVersionwrites"kind", and the Conversation upsert writes all threeorigin_*columns. If 0057 dropped them, old workers would fail during the deploy. That includes every Automation save, because the version insert runs in the same transaction.This PR removes them from the schema, so new code stops naming them. I edited the generated 0057 to keep them in the database. The snapshot already treats them as dropped. Migration 0058 drops them in a follow-up PR after this one deploys. Until then,
conversation-sql.test.tsignores these columns when it compares the database to the schema. A TODO marks that exception.Bugbot fix from #2183
settleEventAutomationRunsnow passes the dispatch Conversation id. A settled event automation run then gets its Conversation link even when the start write could not set it.event-automations.test.tsclears one run's link and checks that the heartbeat fills it. The test fails without the fix.Tests
scheduled-automations-sql.test.ts: the legacy Scheduler adoption scenario now checks the rows injunior_automations, because the old table is gone.conversation-sql.test.ts: the pending-drop exception described above, and the origin index removed from the expected indexes.Refs #2176
via Junior system actor
event.--
View Junior Session [Sentry]