-
Notifications
You must be signed in to change notification settings - Fork 3
[Overview] Prisma
Prisma is an ORM
- Object-relational mapping (ORM) is a way to align programming code with database structures
With Prisma, you can write schemas and models easily without touching SQL (unless you want to customize your database migrations)
Prisma auto-generates SQL migrations from your defined schemas for you. Migrations are simply SQL files that create/alter tables to look like your schemas. These migration files are stored in /prisma/migrations
and act as the source of truth for all coders in your project
Prisma also generates types (as in Typescript) and CRUD functions on the models for you to use directly in the Javascript/Typescript code
There are 3 simple steps you must always do:
Go to /server/prisma/schema.prisma
Make necessary changes to the models
You can reference this link to learn more about the syntax
You can accomplish this simply by running npm run pdev -- --name your_migration_name
You can go to /server/package.json
to see what command runs underneath npm run pdev
You can simply run npm run pgen
For step 2 (generate a migration and push to database) to run, you need to have Docker running first.
To get Docker running, please reference to [Overview] Docker
doc.