Skip to main content

Relational databases

Learn how to create a new TypeScript project with a Prisma Postgres database from scratch. This tutorial introduces you to the Prisma CLI, Prisma Client, and Prisma Migrate and covers the following workflows:

Prerequisites

To successfully complete this tutorial, you need:

See System requirements for exact version requirements.

Create project setup

Create a project directory and navigate into it:

mkdir hello-prisma
cd hello-prisma

Next, initialize a TypeScript project and add the Prisma CLI as a development dependency to it:

npm init -y
npm install prisma typescript ts-node @types/node --save-dev

This creates a package.json with an initial setup for your TypeScript app.

Next, initialize TypeScript:

npx tsc --init

You can now invoke the Prisma CLI by prefixing it with npx:

npx prisma

Next, set up your Prisma ORM project by creating your Prisma Schema file with the following command:

npx prisma init

This command did the following:

  • It created a new directory called prisma that contains a file called schema.prisma, which contains the Prisma schema with your database connection variable and schema models
  • It created a .env file in the root directory of the project, which is used for defining environment variables (such as your database connection and API keys).

In the next section, you'll learn how to connect your Prisma Postgres database to the project you just created on your file system.