For the complete documentation index, see llms.txt. Prefer markdown by appending.mdto documentation URLs or sendingAccept: text/markdown.
Database issues
Diagnose local and remote D1 drift, missing application tables, generated schema overwrites, and seed users with unchanged passwords.
Always identify which database you are inspecting before changing it. The local replica under .wrangler/ and remote D1 have separate migration histories and data.
A migration is missing in production
Check that the missing migration exists under drizzle/, migrations_dir still points there, and the configured DB is your production database. Compare the histories:
pnpm exec wrangler d1 migrations list DB --local
pnpm exec wrangler d1 migrations list DB --remoteThe deploy script applies pending remote migrations before uploading the Worker. Read its migration output, not only the final upload result. If a build failed first, remote migrations did not run. See migrations.
Fix missing local tables
Use local SQL Studio to inspect the current tables and rows in your development replica.
Run pnpm db:migrate --local, then inspect the local table list:
pnpm exec wrangler d1 execute DB --local --command "SELECT name FROM sqlite_master WHERE type = 'table';"Use the same checkout and default persistence location for Vite, Wrangler, and the seed script. A second clone or custom --persist-to path can create a different replica. The browser test harness also prepares its own test state, so do not expect its records to appear in the development database.
Recover an overwritten schema
pnpm db:generate regenerates src/db/schema/auth.ts from Better Auth and then runs Drizzle Kit. It overwrites that auth file only. Your application tables belong in other files under src/db/schema/, exported from src/db/schema/index.ts. Drizzle Kit already reads that barrel.
Restore the table definition from your working history, export it using schema changes, and inspect the generated SQL. Do not apply a migration that drops application tables because generation stopped seeing them. For application-only changes, run pnpm exec drizzle-kit generate.
The seeded user cannot sign in
The seed creates a verified user and a password account if one is missing. For an existing password account, it does not replace the password with a new SEED_PASSWORD value.
Use the original local password, complete a password reset in development, or seed a new email address with the desired password. If Playwright uses E2E_USER_* overrides, make sure they refer to the account that actually exists. Run pnpm db:seed only for local development.
Reset disposable local data
pnpm db:setup migrates and seeds; it is not a reset command. The kit does not ship db:reset.
Stop Vite and any local Wrangler or test process first. Locate the d1 directory within your checkout's .wrangler/state/; the nested layout depends on the installed tooling. Move that D1 directory to a backup outside .wrangler/state/. Preserve the whole directory, including SQLite sidecar files. If you use a custom persistence path, identify its D1 state instead.
Leave the R2 and other local binding directories in place. Deleting all of .wrangler/state also discards local uploads and unrelated state.
Run pnpm db:setup to create the new local D1 state, then restart development. Keep the backup until you have verified the result. This procedure applies only to disposable local data and does not affect remote D1.
Recover a failed migration
Inspect the migration error, applied history, and current table shape. Keep the previous Worker compatible with additive schema changes because migration happens before upload.
Do not edit an already applied migration or pretend redeploying old code reverses a schema change. Review D1 recovery and migration deployment, then prepare a corrective migration or use an appropriate database recovery point.
How is this guide?
Last updated on
Local development
Common development configuration issues, including environment values, Cloudflare account access, generated files, sign-in, and local email.
Deployment
Production troubleshooting for builds, migrations, credentials, billing notifications, email, AI, and Cloudflare Worker compatibility.