Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesFirst identify your database state: a new or empty PostgreSQL database needs Prisma models and a migration; a populated database needs introspection. Then choose a Prisma major version and keep its setup commands together. Prisma’s current documentation describes ORM 8 as a release candidate and ORM 7 as supported, so the walkthrough below is explicitly for ORM 7 and should not be mixed with ORM 8 commands.
Choose the right setup route
| Your starting point | Use this route | What changes |
|---|---|---|
| New app or empty PostgreSQL database | Prisma PostgreSQL quickstart | Define models in Prisma schema and create tables with the version-specific migration workflow. |
| Existing app, empty database | Add Prisma ORM and PostgreSQL to an existing app | Keep the existing application setup and add Prisma before creating tables. |
| Existing PostgreSQL database with tables | Add Prisma ORM to an existing PostgreSQL project | Introspect the current database rather than treating it as empty; use a development copy while onboarding. |
| Using ORM 8 | ORM from-scratch guide | Follow ORM 8 documentation and terminology rather than copying ORM 7 commands. |
Check prerequisites and version
The ORM 7 PostgreSQL quickstart assumes a TypeScript Node.js project and a PostgreSQL server that the app can reach. Have the host, port, username, password, and database name ready. The connection string belongs in DATABASE_URL; keep real credentials out of source control and use a local environment file or a secret manager appropriate to your deployment.
Prisma’s current documentation labels ORM 8 a release candidate while ORM 7 remains supported. The steps below follow the ORM 7 PostgreSQL quickstart; consult its versioned instructions for exact package versions and any prerequisites that may have changed.
ORM 7: add Prisma to a new or empty PostgreSQL database
1. Install the ORM 7 packages
The documented ORM 7 setup uses the Prisma CLI and client, the PostgreSQL driver adapter, the pg driver, and dotenv. For the TypeScript sample, it also includes TypeScript tooling and Node.js type definitions. Use the package-install commands in the ORM 7 PostgreSQL quickstart so the packages match that version; do not substitute a command from the unversioned ORM 8 guide.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
2. Initialize Prisma and configure the connection
In ORM 7, initialize the project with prisma init, selecting PostgreSQL as the provider. The documented setup uses a Prisma config file to load DATABASE_URL from .env, while prisma/schema.prisma declares the datasource provider and models. Put your own connection string in the environment file, for example as a placeholder pattern:
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=public"
Rank #2
Replace every placeholder with the values for your database. Do not commit an environment file containing a usable password.
3. Define a Prisma model
Add a model to prisma/schema.prisma. This minimal example represents a table for application users; adapt field names and types to the application rather than assuming it matches an existing schema.
Rank #3
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
In this new-database route, the model is the starting point for creating the corresponding database table. For a populated database, use introspection instead of inventing a replacement model and applying an initial migration.
4. Create the migration and generate the client
With the ORM 7 CLI, create and apply the initial development migration, then generate Prisma Client:
npx prisma migrate dev --name init
npx prisma generate
Run these commands against a development database, not as a substitute for a production deployment procedure. The generated client must exist before application code imports it.
5. Connect through the PostgreSQL adapter and query
ORM 7’s documented PostgreSQL pattern constructs PrismaPg from the connection string and passes that adapter to PrismaClient. With the packages installed and DATABASE_URL available to the process, a TypeScript example is:
import "dotenv/config";
import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "@prisma/client";
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});
const prisma = new PrismaClient({ adapter });
const users = await prisma.user.findMany();
console.log(users);
await prisma.$disconnect();
The query returns rows from the mapped User table. In a long-running application, manage the client according to the app’s lifecycle rather than creating a new client for each request.
If PostgreSQL already contains tables
Do not run the empty-database model-and-initial-migration sequence blindly against a populated database. Prisma’s existing-project guide describes a distinct onboarding route: work with a development copy, initialize Prisma for the project, introspect the existing schema, and then follow the guide’s steps for applying subsequent changes. Introspection derives Prisma models from the tables already present; it is not the same operation as creating those tables from a new Prisma model.
ORM 8 uses a different documented workflow
The current Prisma documentation calls ORM 8 a release candidate. It describes contract emit as replacing ORM 7’s prisma generate, and migration planning and application as replacing the migrate dev flow. Use the current ORM PostgreSQL quickstart for ORM 8 setup rather than combining those terms with the ORM 7 package, config, or code examples above. Release-candidate details may change.
Quick Recap
Troubleshoot the first setup
- Connection failures: check that
DATABASE_URLhas the right host, port, database, username, and password, and that PostgreSQL is reachable from the machine running the command. - Unexpected schema or config errors: confirm that the project uses the documented Prisma config location and schema path for the chosen major version.
- Adapter import or client construction errors on ORM 7: verify that both
@prisma/adapter-pgandpgare installed and that the adapter instance is passed intoPrismaClient. - Client import or missing generated output: run the generation step for ORM 7 after schema changes, then check the import against the generated client setup.
- Command not recognized or mismatched behavior: check the installed Prisma major version and use only that version’s initialization, migration, and generation workflow.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




