1001Ferramentas
🔺Dev

Prisma Init Generator

Generate an initial schema.prisma.



  

Starter schema.prisma with Postgres and User

Starting with Prisma almost always means copying the schema from an older project, because the syntax of the generator and datasource blocks is not something you type from memory. Add the model attributes on top of that, the @id, the @default(autoincrement()), the question mark that marks an optional field, and ten minutes are gone before your first migration.

The tool shows one complete, fixed schema with nothing to choose, already on screen when the page opens. You get a generator client block with provider prisma-client-js, a datasource db block with provider postgresql and url reading env("DATABASE_URL"), and a User model with an autoincrementing Int id, a unique String email, an optional String name and a createdAt DateTime defaulting to now(). The file belongs at prisma/schema.prisma.

After pasting, create a .env at the project root with DATABASE_URL pointing at your database, in the form postgresql://user:password@localhost:5432/name. Prisma reads that file on its own. Then run npx prisma migrate dev --name init, which applies the migration and generates the client. If your database already exists with tables, skip this schema and run npx prisma db pull instead, which builds models from what is really there. Runs in your browser.

Frequently asked questions

Can I pick MySQL or SQLite on the page?
There is no selector. Change the provider in the datasource block by hand; for SQLite also replace the env variable with url = "file:./dev.db".
Do I still need to run prisma init?
Not necessarily. init creates the prisma folder, the schema and a sample .env. With this text you create both files yourself and skip that step.
How do I generate the Prisma Client?
Run npx prisma generate. If you run npx prisma migrate dev, generate already runs for you at the end of the process.

Related Tools