This is my memo when I tried t3 app with PostgreSQL for the first time.
Pre-requirements: install postgresql
OS: macOS
psql postgres
to enterpostgres
- Create an user with
CREATEDB
permission:CREATE ROLE <username> WITH LOGIN PASSWORD '<password>' CREATEDB;
- go to your app’s root folder
- make sure the provide is ‘postgresql’ at
prisma/schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
5. 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.
6. npx prisma migrate dev --name initial
Special thanks: https://www.codementor.io/@engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb