1- Install Prisma: If you haven't installed Prisma yet, run the following commands to install it:
npm install prisma --save-dev
npx prisma init
2- Update the prisma/schema.prisma file:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
3- Set the correct DATABASE_URL in your .env file, such as:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
4- To generate prisma modal from existing tables
npx prisma db pull
/* This command will introspect the existing database and
automatically generate models in the `prisma/schema.prisma` file
based on the structure of your tables. */
5- Once the introspection is done, you can generate Prisma Client to interact with your database.
npx prisma generate
Top comments (0)