Getting started; To get Prisma into a project we need to take a few steps such as installing it & adding the package. Connecting it to our database & set it up for migrations.
- 1. Add it to project:We could also install it globally:
1npm install prisma --save-dev
1npm i -g prisma
- 2. Check it's installed by listing the version
1prisma -v 25.13.0
- 3. Initialize it & this will create our directory prisma & schema.prisma file
1prisma init
- 4. Pull the database; this is a good resource to baseline our database.
1prisma db pull
- 5. First create a migrations directory:
1mkdir -p prisma/migrations/0_init
- 6. This command reads your Prisma schema and generates your Prisma Client library:
1npx prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > prisma/migrations/0_init/migration.sql
So now basically Prisma is installed; initialized in the project & ready to make updates.