Skip to content

Commit

Permalink
(feat): Add basic schemas for database
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasberggren committed Apr 9, 2024
1 parent 2abb199 commit 339552f
Show file tree
Hide file tree
Showing 16 changed files with 230 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@
]
},
"prisma": {
"schema": "src/database/schema.prisma"
"schema": "prisma/schema.prisma"
}
}
120 changes: 115 additions & 5 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,7 +1,117 @@
//🧩Don't Edit this file.✨Generated in Tue Apr 09 2024 20:47:08 GMT+0200 (Central European Summer Time)✨
//🧩Don't Edit this file.✨Generated in Tue Apr 09 2024 21:19:58 GMT+0200 (Central European Summer Time)✨
model Account {
id Int @id @default(autoincrement())
streamingService String
username String @unique
password String
user User @relation(fields: [userId], references: [id])
userId Int
subscriptionOffers SubscriptionOffer[]
}

model Actor {
actorId Int @id @default(autoincrement())
firstName String
lastName String
birthDate DateTime?
movies Movie[] @relation("ParticipatesIn")
}

generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model Language {
id Int @id @default(autoincrement())
name String
streamingAvailabilities StreamingAvailability[]
movieTitles MovieTitle[]
subtitles Subtitle[]
}

model Movie {
id Int @id @default(autoincrement())
title String
director String
createdAt DateTime @default(now())
id Int @id @default(autoincrement())
director String
genre String
duration Int
releaseDate DateTime
movieTitle MovieTitle[]
subtitles Subtitle[]
ratings Rating[]
streamingDetails StreamingAvailability[]
actors Actor[] @relation("ParticipatesIn")
}

model MovieTitle {
movieTitleId Int @id @default(autoincrement())
movieId Int
languageId Int
title String
Movie Movie @relation(fields: [movieId], references: [id])
Language Language @relation(fields: [languageId], references: [id])
}

model Rating {
ratingId Int @id @default(autoincrement())
movieId Int
site String
rating Float
link String?
Movie Movie @relation(fields: [movieId], references: [id])
}

model StreamingAvailability {
streamingId Int @id @default(autoincrement())
movieId Int
currentAvailability Boolean
whenBecomesAvailable DateTime?
whenExpires DateTime?
languages Language[]
deepLink String?
Movie Movie @relation(fields: [movieId], references: [id])
StreamingService StreamingService[]
}

model StreamingService {
companyId Int @id @default(autoincrement())
companyName String
subscriptionOffers SubscriptionOffer[]
streamingAvailabilities StreamingAvailability[]
}

model SubscriptionOffer {
subscriptionId Int @id @default(autoincrement())
companyId Int
accountId Int
cost Float
active Boolean
StreamingService StreamingService @relation(fields: [companyId], references: [companyId])
Account Account @relation(fields: [accountId], references: [id])
}

model Subtitle {
languageId Int
movieId Int
Language Language @relation(fields: [languageId], references: [id])
Movie Movie @relation(fields: [movieId], references: [id])
@@id([languageId, movieId])
}

model User {
id Int @id @default(autoincrement())
watchLists Watchlist[]
accounts Account[]
}

model Watchlist {
watchlistId Int @id @default(autoincrement())
userId Int
name String
User User @relation(fields: [userId], references: [id])
}
9 changes: 9 additions & 0 deletions apps/api/prisma/subschemas/account.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
model Account {
id Int @id @default(autoincrement())
streamingService String
username String @unique
password String
user User @relation(fields: [userId], references: [id])
userId Int
subscriptionOffers SubscriptionOffer[]
}
7 changes: 7 additions & 0 deletions apps/api/prisma/subschemas/actor.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
model Actor {
actorId Int @id @default(autoincrement())
firstName String
lastName String
birthDate DateTime?
movies Movie[] @relation("ParticipatesIn")
}
17 changes: 17 additions & 0 deletions apps/api/prisma/subschemas/base.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
////////////////////////////////////////////////////////////////////////////////////////
///// Auto Commented Out by 🅿🆁🅸🆂🅼🅰-🅼🆄🅻🆃🅸🆂🅲🅷🅴🅼🅰 ////////
///// Detected : Datasource and Generator Client ////////
///// You can change this files content is commented or Uncommented Stage. ////////
///// It will take effect after you run npx prisma-multischema ////////
///// Feel free to change Datasource/ Database URL / Provider / Binary Targets ////////
///// DO NOT EDIT in this comment box ////////
///// CHANGE ONLY BELOW THIS LINE. ////////
/////////////////////////////////////////////////////////////////////////////////////////

//generator client {
//provider = "prisma-client-js"
//}
//datasource db {
//provider = "postgresql"
//url = env("DATABASE_URL")
//}
7 changes: 7 additions & 0 deletions apps/api/prisma/subschemas/language.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
model Language {
id Int @id @default(autoincrement())
name String
streamingAvailabilities StreamingAvailability[]
movieTitles MovieTitle[]
subtitles Subtitle[]
}
12 changes: 12 additions & 0 deletions apps/api/prisma/subschemas/movie.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
model Movie {
id Int @id @default(autoincrement())
director String
genre String
duration Int
releaseDate DateTime
movieTitle MovieTitle[]
subtitles Subtitle[]
ratings Rating[]
streamingDetails StreamingAvailability[]
actors Actor[] @relation("ParticipatesIn")
}
8 changes: 8 additions & 0 deletions apps/api/prisma/subschemas/movieTitle.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
model MovieTitle {
movieTitleId Int @id @default(autoincrement())
movieId Int
languageId Int
title String
Movie Movie @relation(fields: [movieId], references: [id])
Language Language @relation(fields: [languageId], references: [id])
}
6 changes: 0 additions & 6 deletions apps/api/prisma/subschemas/movies.prisma

This file was deleted.

9 changes: 9 additions & 0 deletions apps/api/prisma/subschemas/rating.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

model Rating {
ratingId Int @id @default(autoincrement())
movieId Int
site String
rating Float
link String?
Movie Movie @relation(fields: [movieId], references: [id])
}
11 changes: 11 additions & 0 deletions apps/api/prisma/subschemas/streamingAvailability.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
model StreamingAvailability {
streamingId Int @id @default(autoincrement())
movieId Int
currentAvailability Boolean
whenBecomesAvailable DateTime?
whenExpires DateTime?
languages Language[]
deepLink String?
Movie Movie @relation(fields: [movieId], references: [id])
StreamingService StreamingService[]
}
6 changes: 6 additions & 0 deletions apps/api/prisma/subschemas/streamingService.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
model StreamingService {
companyId Int @id @default(autoincrement())
companyName String
subscriptionOffers SubscriptionOffer[]
streamingAvailabilities StreamingAvailability[]
}
9 changes: 9 additions & 0 deletions apps/api/prisma/subschemas/subscriptionOffer.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
model SubscriptionOffer {
subscriptionId Int @id @default(autoincrement())
companyId Int
accountId Int
cost Float
active Boolean
StreamingService StreamingService @relation(fields: [companyId], references: [companyId])
Account Account @relation(fields: [accountId], references: [id])
}
8 changes: 8 additions & 0 deletions apps/api/prisma/subschemas/subtitle.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
model Subtitle {
languageId Int
movieId Int
Language Language @relation(fields: [languageId], references: [id])
Movie Movie @relation(fields: [movieId], references: [id])
@@id([languageId, movieId])
}
5 changes: 5 additions & 0 deletions apps/api/prisma/subschemas/user.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
model User {
id Int @id @default(autoincrement())
watchLists Watchlist[]
accounts Account[]
}
6 changes: 6 additions & 0 deletions apps/api/prisma/subschemas/watchlist.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
model Watchlist {
watchlistId Int @id @default(autoincrement())
userId Int
name String
User User @relation(fields: [userId], references: [id])
}

0 comments on commit 339552f

Please sign in to comment.