Skip to content

Drop APP_DB jobs tables after porting remaining readers to the JOBS service (ADR 0016) - #1394

Merged
kentcdodds merged 1 commit into
mainfrom
devin/1786476604-drop-app-db-jobs-tables
Aug 11, 2026
Merged

kentcdodds merged 1 commit into
mainfrom
devin/1786476604-drop-app-db-jobs-tables

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Intent

Finish ADR 0016's jobs-lane extraction cleanup: every remaining main-worker surface that still read the stale APP_DB copies of jobs/archived_job_artifacts now goes through the JOBS service binding, so the old tables can finally be dropped from APP_DB (soak period accelerated pre-launch per runbook step 8).

Summary

  • Migration 0010-drop-jobs-tables.sql drops jobs and archived_job_artifacts from APP_DB (ledger entry added).
  • JOBS contract widened (packages/shared/src/jobs/{store,repo}.ts, packages/jobs-worker/src/service.ts): countJobsForUser, sumJobsStorageBytesForUser, listJobStorageIdsForUser, listArchivedJobArtifactsForUser, listAllJobStorageOwners, getJobInsights, purgeUserJobsData.
  • Ported off direct APP_DB SQL: entitlements (scheduled_jobs count + D1 storage-byte recompute/reconcile), user-meter parity, DR exporter inventory, admin insights, account export / user-inventory storage-id discovery (bucket paging merged with jobs-worker ids), account data-target registry, retention dispositions.
  • Account deletion: job data purges via JOBS.purgeUser fail-closed after best-effort cleanup, before the atomic APP_DB delete (jobs rows can no longer join that transaction); deletedRowCounts no longer includes jobs.
  • Local/test plumbing so the fallback createD1JobsStore(APP_DB) is no longer needed in any deployed path:
    • main worker test env gains the JOBS → kody-jobs-test service binding (multi-config wrangler dev resolves it in-process);
    • migrate:local/migrate:e2e/MCP harness also apply the jobs-worker D1 migrations;
    • workers-unit vitest pool gets an auxiliary kody-jobs-test worker (bundled from tools/jobs-test-service.entry.ts) serving the JobsService contract from its own D1.

Testing

  • Full npm run validate green locally (format, lint, typecheck, node+workers unit, e2e, MCP, builds, migrations/guardrails checks).
  • Focused suites for account deletion, export, entitlements, DR exporter, retention dispositions, data targets, user-meter parity.

System changes

  • APP_DB no longer contains job tables; the jobs worker's D1 is the single owner (ADR 0016). Risk: any unported reader would fail with no such table post-deploy — audited FROM jobs / archived_job_artifacts / createD1JobsStore(env.APP_DB) references; remaining hits are jobs-worker-owned code, test fixtures, and docs/migration history.

Link to Devin session: https://app.devin.ai/sessions/c87f412525e94774b5829058620c71a9
Requested by: @kentcdodds

…ervice (ADR 0016)

Co-Authored-By: Kent C. Dodds <me@kentcdodds.com>
@kentcdodds kentcdodds self-assigned this Aug 11, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-1394.kody-a99.workers.dev

Worker: kody-pr-1394
D1: kody-pr-1394-db
KV: kody-pr-1394-oauth-kv

Mocks:

@kentcdodds
kentcdodds merged commit 74f6b37 into main Aug 11, 2026
8 checks passed
@kentcdodds
kentcdodds deleted the devin/1786476604-drop-app-db-jobs-tables branch August 11, 2026 20:37
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