Skip to content

Instantly share code, notes, and snippets.

@spinningcat
Created February 20, 2025 13:55
Show Gist options
  • Save spinningcat/8acae168ae395ddf4e318179738c99b3 to your computer and use it in GitHub Desktop.
Save spinningcat/8acae168ae395ddf4e318179738c99b3 to your computer and use it in GitHub Desktop.
// Models below is not certain can be changed with times.
// I migrated that models right now. If it changes some content in api may change.
// If this case happens. That won't be issue to update apis.
// User Model
model User {
id Int @id @default(autoincrement())
Email String @unique
Name String
Password String
UserType String
CreationTime DateTime @default(now()) // Auto-sets creation time
UpdateTime DateTime? @updatedAt // Auto-updates on modification
DeleteTime DateTime?
// Relation: One User can have many Login records
logins Login[]
}
model Login {
id Int @id @default(autoincrement())
UserId Int // Foreign Key
LoginTime DateTime
LogoutTime DateTime?
AuthCookie String
// Relation: Many Login records belong to One User
user User @relation(fields: [UserId], references: [id])
}
// worker
model Worker{
id Int @id @default(autoincrement())
WorkerName String
WorkerType String
WorkerStatus String?
CreationTime DateTime @default(now())
UpdateTime DateTime? @updatedAt
DeleteTime DateTime?
}
// Media model
model Media {
id Int @id @default(autoincrement())
MediaName String
MediaType String?
MediaExtension String?
MediaStatus String?
CreationTime DateTime @default(now())
UpdateTime DateTime? @updatedAt
DeleteTime DateTime?
MediaTags MediaTags[] @relation("MediaMediaTags") // Define relation to MediaTags
MediaKeywords MediaKeywords[] @relation("MediaMediaKeywords") // Define relation to MediaKeywords
}
// MediaTags model
model MediaTags {
id Int @id @default(autoincrement())
TagName String
mediaId Int
media Media @relation("MediaMediaTags", fields: [mediaId], references: [id]) // Define relation back to Media
}
// MediaKeywords model
model MediaKeywords {
id Int @id @default(autoincrement())
Keywords String
mediaId Int
media Media @relation("MediaMediaKeywords", fields: [mediaId], references: [id]) // Define relation back to Media
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment