Migrate from Prisma + Postgres
This is the most mechanical of the migrations — and the one with the sharpest type edges. Prisma models map cleanly to Drizzle tables, but D1 is SQLite: no native date, jsonb, decimal, array, or enum types, and Postgres-specific SQL (window functions, FTS, jsonb operators) needs rework. This page surfaces those costs before you start.
pnpm create microservices-app@latest my-app --template saas-starter-sveltekit Local-first · no login · Node ≥ 20 · driven by the prisma-postgres-to-d1 agent skill
Concept mapping
| Prisma + Postgres | microservices.sh / Cloudflare | Note |
|---|---|---|
| String @id @default(uuid()) | text primary key | Generate ids in app, not the DB |
| Int @id @default(autoincrement()) | integer primary key autoincrement | |
| DateTime | integer (epoch ms) or text (ISO) | SQLite has no native date type |
| Boolean | integer 0/1 | |
| Json | text + JSON helpers | No native jsonb |
| Decimal | integer minor units (cents) | No exact decimal — store money as integer cents |
| enum / String[] | text + app check / join table | No native enum or array |
| @relation / @@index | Drizzle references() + index() | D1 enforces FKs only with pragma on |
The migration
Read schema.prisma — models, relations, indexes, enums, defaults — and flag Postgres-specific query features (raw SQL, jsonb ops, FTS, window functions).
Start fresh with create microservices-app, or in an existing app check which entities a module already owns and don't redefine them.
Convert each model per the type mapping, recreate every @@index/@@unique as Drizzle index()/unique(), and move id generation into the app.
Replace Prisma Client calls with Drizzle, rewrite $queryRaw Postgres SQL as SQLite-compatible SQL, and re-express jsonb/array/FTS logic as app code or join tables.
Export Postgres, transform values to SQLite types (dates→epoch, booleans→0/1, JSON→text, decimals→cents), load to local D1, verify counts and joins before remote import.
What doesn't port 1:1
pnpm create microservices-app@latest my-app --template saas-starter-sveltekit Lands on these modules