1# PSL-first Prisma and Effect
2
3This example deploys the same Worker, Hyperdrive, and Neon application as
4[the TypeScript-first example](../cloudflare-neon-prisma). Its authoritative schema
5is `src/prisma/contract.psl`. There is no handwritten TypeScript contract.
6
7`prisma.config.ts` registers `withEffect` on Prisma's ORM configuration. Generation
8emits canonical `contract.json` and `contract.d.ts` plus a thin `makeDatabase`
9factory and standalone Effect row schemas:
10
11```ts
12import { makeDatabase } from "./prisma/generated/client.ts";
13import { schemas } from "./prisma/generated/schemas.ts";
14
15const db = yield* makeDatabase(connection.connectionString);
16const users = yield* db.orm.public.User.all();
17```
18
19`src/Api.ts` validates newly created rows through `schemas.public.User`. The schema
20module can also be used without a database client. These are scalar database row
21validators, not create inputs or public API definitions.
22
23## Run
24
25From the repository root, install dependencies with `pnpm install`, then:
26
27```sh
28cd examples/cloudflare-neon-prisma-psl
29pnpm generate
30pnpm exec tsc --noEmit
31pnpm deploy
32pnpm test
33pnpm destroy
34```
35
36Configure Alchemy's Cloudflare and Neon credentials first. The tests deploy real
37resources and clean them up. Set `ALCHEMY_PROFILE=testing` when using that profile.
38`deploy` and `dev` regenerate before loading the application. Generation itself
39is offline; Prisma migration planning and application happen during deployment.
40
41For source edits, run `pnpm generate:watch` alongside your development process.
42Run generation before type checking and bundling in CI. Do not edit generated
43files. This is Alchemy's Prisma 8 contract consumer, not a Prisma 7 generator block.