how to setup:

  1. Generate a docker-compose.yml file. Make sure the nesting of statements is correct. Download a template here: https://gist.github.com/kmankan/e2d9414a15a669af21840cce146e7201

  2. Go to the directory where your .yaml file is and initialise docker-compose up

docker compose up
  1. In your .env file save the Database URL:
DATABASE_URL=postgresql://postgres:postgres@localhost:10004

change the port at the end to whatever your port is specified to in the docker file
  1. install Prisma
bun add -d prisma

bun add @prisma/client

bunx prisma init

4. this will generate the schema fileOpen `prisma/schema.prisma`. Then create your schema and generate. then run initial migration.  

bunx prisma generate

5. to migrate db:
bunx prisma migrate dev

and when you're writing a .ts file to do prisma commands remember to include this at the begining  
import { PrismaClient } from '@prisma/client'
  1. Create your db schema in the ‘schema.prisma’ file that gets autogenerated. Remember to change the url name to be whatever it is named in your env file from Step 2.
// This is your Prisma schema file,
 
// learn more about it in the docs: https://pris.ly/d/prisma-schema
  
 
// Book (ID, Title, Author, ISBN)
 
// Author (ID, Name, Biography)
 
// Genre (ID, Name)
 
// Member (ID, Name, Email, Address)
 
  
 
generator client {
 
provider = "prisma-client-js"
 
}
 
  
 
datasource db {
 
provider = "postgresql"
 
url = env("DATABASE_URL")
 
}
 
  
 
model Book {
 
id String @id @default(cuid())
 
title String
 
authorId String
 
author Author @relation(fields: [authorId], references: [id]) // Book can have one author
 
genres Genre[] // Book can have multiple genres
 
ISBN String @unique
 
memberId String
 
member Member @relation(fields: [memberId], references: [id]) // Book can only have one member borrowing it
 
}
 
  
 
model Author {
 
id String @id @default(cuid())
 
name String
 
biography String?
 
Book Book[] // Author can have multiple Books
 
}
 
  
 
model Genre {
 
id String @id @default(cuid())
 
name String
 
books Book[] // Each Genre as a category can have multiple books
 
}
 
  
 
model Member {
 
id String @id @default(cuid())
 
name String
 
email String @unique
 
address String?
 
books Book[] // Member can have multiple Books borrowed
 
}