chore(database): drop the dead tables and columns (cleanup round 2, 2/2)

Merged
DA
6d ago
+3951-186

Summary

Cleanup round 2, step 2, PR 2 of 2 (Dean approved: do #2). The contract half: the migration that drops what #2351 stopped declaring.

#2351 is live in production:

  • It merged as 651e41e1 at 12:32Z.
  • Production recorded its migration 20261013120444_dead_tables_pending_drop in effect_sql_migrations at 12:32:28Z.
  • GitHub's Production deployment for 651e41e1 reported Vercel "Deployment has completed" at 12:35:39Z.
  • This PR merges no earlier than an hour after that, the README's go-live window.

20261013123642_dead_tables_drop (custom, every statement IF EXISTS) drops:

  • tables: events, provider_cursors, provider_key, roster_snapshot, transcript_mark, observation_pass, workspace_file, workspace_embedding, devices, account_workspace_preference, introduction_usage
  • columns: account_preference.default_workspace_provider, plus on conversations:
    • provider_id, provider_session_id, workspace
    • spawned_by_message_id, completion_delivered_at
    • next_event_seq
    • memory_flush_operation_id, memory_flush_outcome, memory_flushed_at
  • indexes: conversations_observed_session and conversations_undelivered_children
  • drizzle schema: it holds only the old runner's drizzle.__drizzle_migrations, its sequence, and its types, so DROP SCHEMA IF EXISTS "drizzle" CASCADE removes exactly that.

provider_key is NOT the BYOK table. BYOK keys are account_provider_key (migration 0080_account_provider_key), which this PR leaves alone. provider_key is the earlier vault table, which no module has declared since #2351.

Kept, because they're live: a child conversation's parent_conversation_id, label, title, expects_completion.

Safety

  • Snapshot: Neon snapshot pre-dead-tables-drop-2026-10-13 (snap-still-meadow-au04oyvh) taken of production at 12:37:54Z. On top of that, the project keeps 24h of point-in-time restore (history_retention_seconds: 86400).
  • Re-verified against the live release 651e41e1: no source under packages/ or apps/web/{server,eve,coder} names a dropped table or column. Two hits aren't the database: packages/guide's desktop-local default_workspace_provider setting key, and a coding agent's provider_key failure code. pg_stat_user_tables shows the dead tables' latest index scans fit foreign-key cascades, not reads: for example events, last read 2026-10-12T17:32, when deleting messages cascades into it.
  • No live table has a foreign key into a dropped table; the only foreign key on a dropped column is conversations.spawned_by_message_id → messages, which goes with it.

Rows dropped in production:

TableRows
events2155
provider_cursors403
provider_key9
roster_snapshot3
transcript_mark3
observation_pass3
workspace_file65
workspace_embedding380
devices22
account_workspace_preference3
introduction_usage31
drizzle.__drizzle_migrations22
Total3099

Column values dropped:

  • default_workspace_provider: 3 non-null.
  • On the 969 observed conversations (the rows themselves stay): 969 provider_id and 969 provider_session_id values, and 479 workspace values.
  • spawned_by_message_id and completion_delivered_at: 0 non-null.

Tests

  • storage-schema.test.ts's declared-tables list loses the eleven, and the drift check's PENDING_DROP/PENDING_DROP_TABLES entries go, so both fail if the migration doesn't drop them.
  • dead-tables-dropped.test.ts from #2351 goes. Every store suite now runs over the dropped shape.
  • store-writer-boundary.test.ts stops guarding events (its fixtures move to messages/turns).
  • This PR's Vercel Preview branches its Neon database from production and runs this migration through the real migrator: a rehearsal on production's data.

Evidence

  • Platform-independent checks: ./scripts/check.sh exit 0 locally (knip, lint, discarded-effect, typecheck, test all passed)
  • macOS Electron verification (./scripts/verify.sh): not run. No Mac or UI change, and this is a Linux VM; CI cannot verify the Mac (LUKE-159 is the manual Mac pass)

Invariants

  • ./scripts/check.sh green. No renderer/UI change.
  • JSON Schema goldens unchanged.
  • The schema tests that fail without the drop are in this PR; no change-detector test added.
  • Gateway envelope goldens unchanged.
  • No new as type assertion.
  • No Effect.runPromise/runSync/runFork added.
  • No raw async primitive added.
  • No discarded Effect.
  • Test count: āˆ’1 file (dead-tables-dropped.test.ts), as above.
  • No hand-rolled file replaced.
  • apps/web/server/README.md updated; root AGENTS.md/CLAUDE.md untouched.
  • PRIVACY.md unchanged.
  • Package deps unchanged.
  • Barrel/door rule untouched.

Notes

  • Restore path if needed: Neon snapshot snap-still-meadow-au04oyvh, or point-in-time restore of production to before this migration's timestamp in effect_sql_migrations.

šŸ¤– Generated with Claude Code


Open workspace in Conductor


Devin Review