Database Development
Change the D1 schema and apply a reviewed migration
For initial setup, use Cloudflare D1. This page is for adding or changing tables after your site works.
Change a table
- Find the relevant schema in
src/db/. Follow the existing SQLite column definitions and indexes. - Ask your coding tool to update the corresponding queries in
src/shared/model/and service behavior insrc/services/. - Generate the migration:
pnpm db:generate- Read the new SQL file in
drizzle/. Check whether it removes columns, tables, or existing data. Back up production data before applying a destructive change. - Apply the migration locally and verify the affected feature:
pnpm db:migrate:local
pnpm typecheck
pnpm testAfter checking the local result, apply it to the intended production database:
pnpm exec wrangler d1 migrations apply shipstart-db --remoteReplace the database name if you renamed it. Deploy the application code together with the compatible schema change.
Useful files
| Path | Purpose |
|---|---|
src/db/ | SQLite schema definitions |
drizzle.config.ts | Migration generation configuration |
drizzle/ | SQL migrations and metadata |
src/shared/model/ | Database queries |
src/services/ | Application operations |
wrangler.jsonc | Local and production D1 bindings |
D1 provides the database binding; this project does not use a DATABASE_URL connection string. See the D1 migration documentation when planning a production schema change.