D1 Cheatsheet

Quick commands for local D1 debugging.


List tables

wrangler d1 execute database --local --command="SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"

List users

wrangler d1 execute database --local --command="SELECT * FROM users ORDER BY email;"

List accounts

wrangler d1 execute database --local --command="SELECT * FROM accounts ORDER BY account_id;"

Generate migrations

npm run db:generate --workspace workers/app