For the database, we have used postgresql
which is a great database service.
and prisma
as an ORM for the database.
Now let's setup Database
in your application.
- Go to the NeonDB (opens in a new tab) and create a new project and database. Get the connection string and update it in the
.env
file.
.env
DATABASE_URL=
NeonDB is a great service for the database, you can also use other services like Heroku (opens in a new tab) or AWS (opens in a new tab).
- Now, head over to the
prisma/schema.prisma
file and you can see there is some schema defined for the authentication purpose. You can update it according to your needs.
- Now go ahead and run the following command to generate the prisma client.
terminal
cd src # make sure you are in the src folder before running migration
# because prisma client will be generated in the src folder.
npx prisma generate
npx prisma db push
This will generate the prisma client and also create the tables in the database.
- Now, you can see the tables in the database and you can also see the prisma client generated in the
src
folder.
That's it, you have successfully set up the database for the project. You can now use the prisma client to interact with the database.
Great work 👏👏👏, Now let's setup authentication for our users.