Migrations Applied

Append-only log of remote-database migrations applied by hand. Each entry records the pre-state (so the reader knows if the apply was a real change or an idempotent no-op), the apply result, and a post-verify summary.

Workflow:

  1. Apply the migration via the documented tool (wrangler / cockroach).
  2. Run the post-flight check listed in the migration file.
  3. Append a new entry to this file (newest at the top of the History list).
  4. Commit.

The list of migration files in the repo lives in migrations/ (CV / D1) and jobcache/migrations/ (JC / CockroachDB). Not every file in those folders has been applied to remote — apply state is tracked here.

History

2026-08-17 - CV Smart Routing explanations

  • Migration file: migrations/add-ai-routing-explanations.sql
  • Target: Cloudflare D1 careervector (id 5c785fa1-c421-4ee8-8737-53484c9f3979), remote.
  • Pre-state: none of routing_reason, routing_policy, recommended_provider_id, or recommended_model existed on ai_usage.
  • Apply result: wrangler 4.93.0 reported Processed 4 queries; 876 rows read, 4 rows written, changed_db: true, bookmark 00002d91-00000006-000050ca-c0dca0f8e0b14c17d56c6d43ee9e836b.
  • Post-verify: all four columns exist with type TEXT. They store only typed reason/policy codes and provider/model identifiers; no prompts, outputs, credentials, or routing-state snapshots.
  • Authorized by: Julian, in chat.

2026-08-17 - CV immutable RADAR snapshots and composite corpus cursors

  • Migration files: migrations/tighten-radar-snapshots.sql, then migrations/add-corpus-composite-cursors.sql.
  • Target: Cloudflare D1 careervector (id 5c785fa1-c421-4ee8-8737-53484c9f3979), remote production environment.
  • Recovery point: pre-apply Time Travel bookmark 00002d88-00000000-000050ca-baf6206003d78427b9a53a8626de552f.
  • Pre-state: 6 radar_searches, no workspace pointers or impressions, 2 corpus cursors, no active corpus leases, and PRAGMA quick_check returned ok.
  • Apply result: wrangler 4.93.0 processed 12 queries for the RADAR upgrade (815 rows read, 23 rows written), then 18 queries for the cursor/protocol upgrade (2,403 rows read, 95 rows written). Both imports reported changed_db: true; final bookmark 00002d90-00000010-000050ca-74e171717d5ec42db48d2862f0bbfe29.
  • Post-verify: immutable snapshot columns and trigger, workspace grants, impression-set identity, cursor_seq, all 5 lease/receipt/quarantine tables, and all 4 global source indexes are present. The 6 snapshots and both cursor rows were preserved, active leases remain 0, conservative sequences are 0, and PRAGMA quick_check returns ok.
  • Authorized by: Julian, in chat.

2026-08-17 - CV adaptive LLM tensor learning

  • Migration file: migrations/add-llm-tensor-learning.sql
  • Target: Cloudflare D1 careervector (id 5c785fa1-c421-4ee8-8737-53484c9f3979), remote.
  • Pre-state: none of the llm_tensor_* or llm_budget_* tables existed.
  • Apply result: wrangler 4.93.0 reported Processed 10 queries; 13 rows read, 24 rows written, changed_db: true, bookmark 00002d71-00000008-000050ca-c34d2af12e802adf41f8487f4f5c2085.
  • Post-verify: all seven tensor and budget tables exist. llm_budget_accounts exposes unit_kind (TEXT) and integer limit_units, spent_units, and reserved_units columns.
  • Authorized by: Julian, in chat.

2026-05-30 - CV FinOps stale CI source cleanup

  • Migration file: migrations/drop-ops-finops-old-ci-meter.sql
  • Target: Cloudflare D1 careervector (id 5c785fa1-c421-4ee8-8737-53484c9f3979), remote.
  • Pre-state: one ops_finops_meters row used an unsupported FinOps source, with one dependent ops_finops_limits row.
  • Apply result: wrangler reported Processed 2 queries; 204 rows read, 2 rows written, changed_db: true, bookmark 00002815-0000002a-0000507b-1585ce32dc23396266d243880eb649d7.
  • Post-verify: unsupported FinOps source rows = 0; orphaned FinOps limit rows = 0.
  • Authorized by: Julian, in chat.

2026-05-17 — JC scrape_events

  • Migration file: jobcache/migrations/add-scrape-events.sql
  • Target: CockroachDB Cloud, cluster jobcache (id 534fcc9a-4219-4282-a5c8-45f550c8921a), AWS eu-central-1, database jobcache, Basic plan.
  • Pre-state: table scrape_events did not exist.
  • Apply result: CREATE TABLE (inline INDEX clauses created with it). Single statement; success.
  • Post-verify: table present in information_schema.tables. Four secondary indexes present in information_schema.statistics (idx_scrape_events_ts, idx_scrape_events_source, idx_scrape_events_type, idx_scrape_events_run) plus scrape_events_pkey. Sanity-write inserted+selected (count=1) then deleted (final count=0).
  • Authorized by: Julian, in chat.

2026-05-17 — JC operator_actions

  • Migration file: jobcache/migrations/add-operator-actions.sql
  • Target: CockroachDB Cloud, cluster jobcache (id 534fcc9a-4219-4282-a5c8-45f550c8921a), AWS eu-central-1, database jobcache, Basic plan.
  • Pre-state: table operator_actions did not exist.
  • Apply result: CREATE TABLE + 3 × CREATE INDEX. All succeeded.
  • Post-verify: table present in information_schema.tables. Three secondary indexes present in information_schema.statistics (idx_operator_actions_ts, idx_operator_actions_target, idx_operator_actions_action) plus operator_actions_pkey. Sanity-write inserted+selected (count=1) then deleted (final count=0).
  • Authorized by: Julian, in chat.

2026-05-17 — CV operator_actions

  • Migration file: migrations/add-operator-actions.sql
  • Target: Cloudflare D1 careervector (id 5c785fa1-c421-4ee8-8737-53484c9f3979), remote.
  • Pre-state: table operator_actions did not exist.
  • Apply result: wrangler reported Processed 6 queries (1 × CREATE TABLE + 5 × CREATE INDEX); 11 rows read, 8 rows written, changed_db: true.
  • Post-verify: sqlite_master shows operator_actions table plus all five expected indexes (idx_operator_actions_action, idx_operator_actions_actor, idx_operator_actions_state_override, idx_operator_actions_target, idx_operator_actions_ts) plus the implicit sqlite_autoindex_operator_actions_1 for the PK. Sanity-write inserted+selected (count=1) then deleted (final count=0).
  • Authorized by: Julian, in chat.

How to apply a new migration

CV D1

# Credentials sourced one value at a time from
# ~/agents/mind/secrets/cloudflare.yml with sops (do not print).
CLOUDFLARE_EMAIL=... CLOUDFLARE_API_KEY=... \
    npx wrangler d1 execute careervector --remote \
        --file=migrations/<name>.sql

JC CockroachDB

# Connection string from `pulumi stack output --show-secrets databaseUrl`
# in jobcache/infra (do not print). Requires the `cockroach` CLI binary.
CRDB_CONN_STRING=... \
    cockroach sql --url "$CRDB_CONN_STRING" \
        --file jobcache/migrations/<name>.sql

After the apply, run the post-flight verification from the migration's own header (each migration file documents what should exist after a successful apply), then append a History entry above.

Source: wiki/content/runbooks/MIGRATIONS-APPLIED.md