IntegrationsDatabase
In this example we will see how to configure your database.
I will show you how to configure both a SQLite and a PostgreSQL database.
The procedure to configure most SQL supported byPrismais the same.
Setup SQLite
- Rename
.env.example
to.env
if you didn't do it yet. - Open the command line and run this commands:
npm run prisma:generate
npm run prisma:migrate
- That's it! You are ready to go!
Configure Postgres
If you prefer postgres, it's as easy as SQLite.
- InstallPostgreson your machine
- Open the command line and run this commands:
psql -U postgres
create role YOUR_DB_USER with encrypted password 'YOUR_DB_USER_PASSWORD' createdb login;
create database YOUR_DB_NAME with owner YOUR_DB_USER;
grant all privileges on database YOUR_DB_NAME to YOUR_DB_USER;
\q # exit the postgres console
- Almost there, change the following lines in your
/prisma/schema.prisma
file:// /prisma/schema.prisma// ...previous code// FROMdatasource db {provider = "sqlite"url = env("POSTGRES_PRISMA_URL")}// TOdatasource db {provider = "postgresql"url = env("POSTGRES_PRISMA_URL")}// ...rest of the file - Done? Fantastic! Last edit I promise! In your
.env
file, change the following line:// /.env// ...previous values// FROMPOSTGRES_PRISMA_URL=file:./dev.db// TOPOSTGRES_PRISMA_URL=postgresql://YOUR_DB_USER:YOUR_DB_USER_PASSWORD@localhost:5432/YOUR_DB_NAME - Open the command line, run this commands, and you're set:
npm run prisma:generate
npm run prisma:migrate