DEV Community

Yuko
Yuko

Posted on • Updated on

How to setup Prisma with your local PostgreSQL

This is my memo when I tried t3 app with PostgreSQL for the first time.

Pre-requirements: install postgresql
OS: macOS

  1. psql postgres to enter postgres

  2. Create an user with CREATEDB permission: CREATE ROLE <username> WITH LOGIN PASSWORD '<password>' CREATEDB;

  3. go to your app’s root folder

  4. make sure the provide is ‘postgresql’ at prisma/prisma.schema

    datasource db {
        provider = "postgresql"
        url      = env("DATABASE_URL")
    }
Enter fullscreen mode Exit fullscreen mode
  1. Database url has the following structure: postgresql://username:password@localhost:5432/database-name
    ⚠️ If you don’t use the default port number, replace from 5432 to yours.

  2. npx prisma migrate dev --name initial

Special thanks: https://www.codementor.io/@engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb

Top comments (0)