Loading...
Skip to main content

Prepare Database

Before we begin to do any coding, we need to update our database. Cerev uses Prisma ORM with Planetscale using MySQL.

Git clone cerev-server and you should see the following file structure;

cerev-server
├── Dockerfile
├── README.md
├── dist
├── nest-cli.json
├── node_modules
├── package-lock.json
├── package.json
├── prisma
├── src
├── test
├── tsconfig.build.json
└── tsconfig.json

This is the root directory of cerev-server, to change schema of the project, go to prisma file, should give you the following;

.prisma
├── schema.prisma
├── seed.ts
└── seeders

Don't have to worry about any files first, just focus on schema.prisma. This is the file that has all the schema of the whole project. Please go through Prisma ORM documentation on how the ORM works.

Now we shall create our model at the end of the file to cater for our Legal Compliance Module.

model LegalCompliance {
id Int @id @autoincrement()
name String
expiryDate DateTime
}

We have created a LegalCompliance table. We still need to push this to our database in PlanetScale so that it would reflect, we will run the following command

npx prisma db push

Once complete, lets get started with creating a controller, and logic.