Skip to Content
JobWzrd Docs

Old Convex schema → new D1 schema: is it an improvement?

Measured on 2026-11-18 from server/convex/schema.ts (frozen) and backend/migrations/*.sql (new). Numbers are counted from the files, not remembered.

DimensionConvex (old)D1 (new)Verdict
Tables4247 (43 product + 4 Better Auth)more, but fewer overlapping concepts
Indexes136 (3.2/table)32fewer; composite FKs and PKs carry the paths
Foreign keys enforced025win
UNIQUE constraints0 (Convex has no unique index)30win
CHECK constraints064win
NOT NULL columns0 (every field is v.optional by default)293win
Untyped holes17 × v.any()12 × TEXT -- JSONmarginal win
Ownership checks27 × userId + manual check in every mutationcomposite FK (id, owner_id) + 4 triggerswin
Erasure modelnoneops_table_policy (one row/table, enforced by test)win
Migration historyConvex handles itops_migrations ledger, files run at most oncewin

What was consolidated (fewer concepts, not fewer features)

OldNewWhy it is better
jobs + cachedJobscorpus_jobs + corpus_job_sourcesone posting = one row (UNIQUE(canonical_url)), N sources per posting; fingerprint + merged_into_id make dedupe/merge explicit instead of implicit
jobMatchResultscolumns on search_results (score, matched_by, explanation)a match only exists inside a search; UNIQUE(search_id, job_id) stops duplicate rows
emailSyncStatecolumns on email_accounts (sync_cursor, last_sync_at, last_sync_status/error)1:1 data stops needing its own table
dailyUsage + rateLimitsops_cap_quota + ops_cap_ledgerappend-only charges with UNIQUE(owner_id, op_key) → a double click cannot charge twice; CHECK (used <= limit_value) is a database backstop on 5 applies / 50 emails
companies, ycIndexShardscorpus_companies, corpus_yc_companies (+ company_notes)companies are entities with a domain key, not index shards
usersauth_user (Better Auth)one identity source instead of a hand-rolled table + adapter
salary: v.any()5 bounded fields in salary JSONno untyped bag
—blobs, email_draft_attachments, outreach_suppressions, ops_outbox, ops_consumer_deliveries, ops_dlq_incidents, profile_linksR2 map, attachments, suppression list and delivery honesty had no home before

What was dropped, and whether it matters

Old tableStatusCost
proxyProviders, proxyEndpoints, proxyAssignments, browserSessionsdroppedproxy pool and browser sessions now live in the scraper process (env + registry), not the product DB. No per-request proxy accounting in the DB — acceptable, it was telemetry
logLinesdroppedlog viewer is memory-only (dev.sh); there is no durable log table any more. Real loss if log history is ever needed
outreachCampaignsdroppednothing in app/src reads a campaign (only utm.ts mentions the word). No user-facing loss found
emailSyncStatefolded into email_accountsnone

What got worse

  1. No interactive transactions. D1 gives db.batch() and single statements only; multi-table invariants must be triggers or batched guarded statements. Convex gave atomic multi-document mutations. This is the biggest ergonomic regression.
  2. 12 TEXT -- JSON columns remain (links, skills, experience, education, achievements, work_authorization, other_urls, dossier, salary, scopes, …). Same class of hole as v.any(), just fewer and named — a comment is not a constraint.
  3. Index count fell 136 → 32. Composite FKs and PKs cover the ownership joins, but any new query path needs an index added deliberately (EXPLAIN QUERY PLAN before shipping), where Convex's index-per-access-pattern habit hid that cost.
  4. D1 limits are real: 100 columns/table, 2 MB row, 100 bound params, 30 s query, 10 GB DB.
  5. Same-name drift: the two schemas use different naming (canonicalUrl vs canonical_url). The shared record in scrapers/contracts/job-record.schema.json is snake_case and the Convex edge maps, so this only bites anyone reading both files side by side.

Answer

Yes — materially, on the things that cost money or leak data. Uniqueness, requiredness, ownership and caps are now enforced by the database instead of by discipline in handlers: a second send cannot be charged twice, a search result cannot point at another owner's search, and used <= limit_value cannot be violated by an application bug. The residual free-form columns and the loss of interactive transactions are the honest costs, and neither is new debt created here — the first existed in Convex as v.any(), the second is D1's platform model.

On this page