T3: D1 + Drizzle schema and migrations #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "t3-d1-drizzle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
T3: D1 + Drizzle
Stacked on #2 (
t2-i18n) → #1 (t1-scaffold). Merge those first.What
src/db/schema.ts:users,sessions,accounts,verifications), fordrizzleAdapter(..., { usePlural: true })in T6.users.username(FIT username) as an additional field.connections: one row per (user, provider ∈fit|gitlab), kindoauth|pat. The token columns are*_encand hold ciphertext only (the T4 crypto envelope).ON DELETE CASCADEonusers.id, so deleting an account is a single hard delete (needed by T23).timestamp_mswith SQL defaults and$onUpdateforupdatedAt.migrations/0000_init.sqlis generated by drizzle-kit (bun run db:generate) and applied locally withbun run db:migrate(wrangler d1 migrations apply fit-os --local).wrangler.jsonc: aDBD1 binding with a placeholderdatabase_id. No Cloudflare resources were created. Regeneratedworker-configuration.d.ts.src/db/client.ts:createDb(env.DB)./api/healthnow probes D1 and returns{ ok, db }, with 503 when the DB or migrations are missing and no error details.node:sqlite, through Drizzlesqlite-proxywithPRAGMA foreign_keys=ONlike D1.@cloudflare/vitest-pool-workersonly supports Vitest 4, and we're on Vitest 5.Verified
bun run lint && bun run typecheck && bun run test(24 tests): migrations apply, round trip,UNIQUE(user_id, provider), FK enforcement, cascade hard delete that leaves other users intact, unique email/username,updatedAtbump.bun run db:migrate→ 14 commands OK.bun run dev+curl /api/health→{"ok":true,"db":"ok"}.unixepoch('subsec')defaults verified in local D1 withwrangler d1 execute --local.Astra review (gpt-6-astra)
accounts.issuer. Dismissed: T6 installs the current 1.7.x (≥1.7.3), which matches this schema. I'll recheck when adding Better Auth.🤖 Generated with Claude Code