Created
June 19, 2022 11:31
-
-
Save sramam/6e6261b8bc97f592a44c25edee4d3d8f to your computer and use it in GitHub Desktop.
journaly-prisma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generator prisma_client { | |
provider = "prisma-client-js" | |
// binaryTargets = ["native", "rhel-openssl-1.0.x"] | |
} | |
datasource db { | |
provider = "postgresql" | |
url = env("DATABASE_URL") | |
} | |
model User { | |
id Int @id @default(autoincrement()) | |
name String? | |
email String @unique | |
handle String @unique | |
userRole UserRole @default(USER) | |
bio String? | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
profileImage String? | |
city String? | |
country String? | |
stripeCustomerId String? | |
moosendSubscriberId String? | |
auth Auth? | |
comments Comment[] | |
commentThanks CommentThanks[] | |
languagesLearning LanguageLearning[] | |
languagesNative LanguageNative[] | |
languages LanguageRelation[] | |
membershipSubscription MembershipSubscription? | |
MembershipSubscriptionInvoice MembershipSubscriptionInvoice[] | |
PendingNotification PendingNotification[] | |
posts Post[] | |
savedPosts Post[] @relation("UserSavedPosts", references: [id]) | |
postComments PostComment[] | |
postCommentSubscriptions PostCommentSubscription[] | |
postCommentThanks PostCommentThanks[] | |
postClaps PostClap[] | |
socialMedia SocialMedia? | |
threadSubscriptions ThreadSubscription[] | |
badges UserBadge[] | |
userInterests UserInterest[] | |
followedBy User[] @relation("UserFollows", references: [id]) | |
following User[] @relation("UserFollows", references: [id]) | |
lastFourCardNumbers String? | |
cardBrand String? | |
notifications InAppNotification[] @relation("notifications") | |
notificationsTriggered InAppNotification[] @relation("notificationsTriggered") | |
newFollowerNotifications NewFollowerNotification[] | |
isStudent Boolean @default(false) | |
} | |
model Auth { | |
id Int @id @default(autoincrement()) | |
userId Int @unique | |
password String | |
resetToken String? | |
resetTokenExpiry Int? | |
emailVerificationToken String? | |
emailVerificationStatus EmailVerificationStatus @default(PENDING) | |
user User @relation(fields: [userId], references: [id]) | |
} | |
model LanguageLearning { | |
id Int @id @default(autoincrement()) | |
userId Int | |
languageId Int | |
createdAt DateTime @default(now()) | |
language Language @relation(fields: [languageId], references: [id]) | |
user User @relation(fields: [userId], references: [id]) | |
@@unique([userId, languageId]) | |
} | |
model LanguageRelation { | |
id Int @id @default(autoincrement()) | |
userId Int | |
languageId Int | |
createdAt DateTime @default(now()) | |
level LanguageLevel | |
language Language @relation(fields: [languageId], references: [id]) | |
user User @relation(fields: [userId], references: [id]) | |
@@unique([userId, languageId]) | |
} | |
model LanguageNative { | |
id Int @id @default(autoincrement()) | |
userId Int | |
languageId Int | |
createdAt DateTime @default(now()) | |
language Language @relation(fields: [languageId], references: [id]) | |
user User @relation(fields: [userId], references: [id]) | |
@@unique([userId, languageId]) | |
} | |
model SocialMedia { | |
id Int @id @default(autoincrement()) | |
userId Int @unique | |
website String | |
youtube String | |
instagram String | |
facebook String | |
user User @relation(fields: [userId], references: [id]) | |
} | |
model Post { | |
id Int @id @default(autoincrement()) | |
title String | |
body String | |
bodySrc String @default("") | |
excerpt String | |
status PostStatus @default(DRAFT) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
authorId Int | |
readTime Int @default(1) | |
wordCount Int @default(0) | |
languageId Int | |
longitude Decimal? | |
latitude Decimal? | |
publishedAt DateTime? | |
bumpedAt DateTime? | |
bumpCount Int @default(0) | |
publishedLanguageLevel LanguageLevel @default(BEGINNER) | |
author User @relation(fields: [authorId], references: [id]) | |
language Language @relation(fields: [languageId], references: [id]) | |
headlineImage HeadlineImage @relation(fields: [headlineImageId], references: [id]) | |
headlineImageId Int @unique | |
PendingNotification PendingNotification[] | |
postComments PostComment[] | |
postCommentSubscriptions PostCommentSubscription[] | |
claps PostClap[] | |
postTopics PostTopic[] | |
threads Thread[] | |
notifications InAppNotification[] | |
savedUsers User[] @relation("UserSavedPosts", references: [id]) | |
privateShareId String? @unique | |
newPostNotifications NewPostNotification[] | |
} | |
model Language { | |
id Int @id @default(autoincrement()) | |
name String | |
dialect String? | |
devName String? | |
learningUsers LanguageLearning[] | |
nativeUsers LanguageNative[] | |
LanguageRelation LanguageRelation[] | |
posts Post[] | |
@@unique([name, dialect]) | |
} | |
model Topic { | |
id Int @id @default(autoincrement()) | |
devName String | |
postTopics PostTopic[] | |
prompt Prompt[] | |
topicTranslations TopicTranslation[] | |
userInterests UserInterest[] | |
} | |
model TopicTranslation { | |
id Int @id @default(autoincrement()) | |
uiLanguage UILanguage | |
name String | |
topicId Int | |
topic Topic @relation(fields: [topicId], references: [id]) | |
@@unique([uiLanguage, topicId]) | |
} | |
model UserInterest { | |
id Int @id @default(autoincrement()) | |
userId Int | |
topicId Int | |
createdAt DateTime @default(now()) | |
topic Topic @relation(fields: [topicId], references: [id]) | |
user User @relation(fields: [userId], references: [id]) | |
@@unique([userId, topicId]) | |
} | |
model PostTopic { | |
id Int @id @default(autoincrement()) | |
postId Int | |
topicId Int | |
post Post @relation(fields: [postId], references: [id]) | |
topic Topic @relation(fields: [topicId], references: [id]) | |
@@unique([postId, topicId]) | |
} | |
model PostClap { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
postId Int | |
authorId Int | |
author User @relation(fields: [authorId], references: [id]) | |
post Post @relation(fields: [postId], references: [id]) | |
PendingNotification PendingNotification[] | |
postClapNotifications PostClapNotification[] | |
@@unique([authorId, postId]) | |
} | |
model CommentThanks { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
authorId Int | |
commentId Int | |
author User @relation(fields: [authorId], references: [id]) | |
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade) | |
PendingNotification PendingNotification[] | |
ThreadCommentThanksNotification ThreadCommentThanksNotification[] | |
@@unique([authorId, commentId]) | |
} | |
model PostCommentThanks { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
authorId Int | |
postCommentId Int? | |
author User @relation(fields: [authorId], references: [id]) | |
PostComment PostComment? @relation(fields: [postCommentId], references: [id]) | |
PendingNotification PendingNotification[] | |
@@unique([authorId, postCommentId]) | |
} | |
model Comment { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
body String | |
authorId Int | |
threadId Int | |
author User @relation(fields: [authorId], references: [id]) | |
thread Thread @relation(fields: [threadId], references: [id]) | |
thanks CommentThanks[] | |
PendingNotification PendingNotification[] | |
authorLanguageLevel LanguageLevel @default(BEGINNER) | |
threadCommentNotifications ThreadCommentNotification[] | |
} | |
model PostComment { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
body String | |
authorId Int | |
postId Int | |
author User @relation(fields: [authorId], references: [id]) | |
post Post @relation(fields: [postId], references: [id]) | |
PendingNotification PendingNotification[] | |
thanks PostCommentThanks[] | |
postCommentNotifications PostCommentNotification[] | |
authorLanguageLevel LanguageLevel @default(BEGINNER) | |
} | |
model Thread { | |
id Int @id @default(autoincrement()) | |
startIndex Int | |
endIndex Int | |
highlightedContent String | |
postId Int | |
archived Boolean @default(false) | |
post Post @relation(fields: [postId], references: [id]) | |
comments Comment[] | |
subscriptions ThreadSubscription[] | |
} | |
model HeadlineImage { | |
id Int @id @default(autoincrement()) | |
smallSize String | |
largeSize String | |
Post Post[] | |
} | |
model Prompt { | |
id Int @id @default(autoincrement()) | |
text String | |
topicId Int | |
topic Topic @relation(fields: [topicId], references: [id]) | |
} | |
model ThreadSubscription { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
userId Int | |
threadId Int | |
thread Thread @relation(fields: [threadId], references: [id], onDelete: Cascade) | |
user User @relation(fields: [userId], references: [id], onDelete: Cascade) | |
@@unique([userId, threadId]) | |
} | |
model PostCommentSubscription { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
userId Int | |
postId Int | |
post Post @relation(fields: [postId], references: [id]) | |
user User @relation(fields: [userId], references: [id]) | |
@@unique([userId, postId]) | |
} | |
model MembershipSubscription { | |
id Int @id @default(autoincrement()) | |
period MembershipSubscriptionPeriod | |
userId Int @unique | |
stripeSubscription Json | |
stripeSubscriptionId String @unique | |
expiresAt DateTime? | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
nextBillingDate DateTime? | |
cancelAtPeriodEnd Boolean @default(false) | |
lastPaymentFailure Boolean @default(false) | |
user User @relation(fields: [userId], references: [id]) | |
} | |
model MembershipSubscriptionInvoice { | |
id Int @id @default(autoincrement()) | |
userId Int | |
membershipSubscriptionPeriod MembershipSubscriptionPeriod | |
stripeInvoiceId String | |
stripeInvoiceData Json | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
user User @relation(fields: [userId], references: [id]) | |
MembershipSubscriptionInvoiceItem MembershipSubscriptionInvoiceItem[] | |
} | |
model MembershipSubscriptionInvoiceItem { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
amount Int | |
currency String | |
description String | |
proration Boolean | |
invoiceId Int | |
stripeInvoiceItemId String | |
stripeInvoiceItemData Json | |
invoice MembershipSubscriptionInvoice @relation(fields: [invoiceId], references: [id]) | |
} | |
model UserBadge { | |
id Int @id @default(autoincrement()) | |
type BadgeType | |
createdAt DateTime @default(now()) | |
userId Int | |
user User @relation(fields: [userId], references: [id]) | |
@@unique([userId, type]) | |
} | |
model PendingNotification { | |
id Int @id @default(autoincrement()) | |
type EmailNotificationType | |
createdAt DateTime @default(now()) | |
userId Int | |
postId Int? | |
postCommentThanksId Int? | |
commentThanksId Int? | |
postCommentId Int? | |
commentId Int? | |
postClapId Int? | |
comment Comment? @relation(fields: [commentId], references: [id]) | |
commentThanks CommentThanks? @relation(fields: [commentThanksId], references: [id]) | |
postComment PostComment? @relation(fields: [postCommentId], references: [id]) | |
postCommentThanks PostCommentThanks? @relation(fields: [postCommentThanksId], references: [id]) | |
postClap PostClap? @relation(fields: [postClapId], references: [id]) | |
post Post? @relation(fields: [postId], references: [id]) | |
user User @relation(fields: [userId], references: [id]) | |
} | |
model InAppNotification { | |
id Int @id @default(autoincrement()) | |
type InAppNotificationType | |
createdAt DateTime @default(now()) | |
bumpedAt DateTime? | |
readStatus NotificationReadStatus @default(UNREAD) | |
postId Int? | |
userId Int | |
post Post? @relation(fields: [postId], references: [id]) | |
user User @relation(name: "notifications", fields: [userId], references: [id]) | |
triggeringUser User? @relation(name: "notificationsTriggered", fields: [triggeringUserId], references: [id]) | |
triggeringUserId Int? | |
threadCommentNotifications ThreadCommentNotification[] | |
postCommentNotifications PostCommentNotification[] | |
newFollowerNotifications NewFollowerNotification[] | |
postClapNotifications PostClapNotification[] | |
threadCommentThanksNotifications ThreadCommentThanksNotification[] | |
newPostNotifications NewPostNotification[] | |
} | |
model ThreadCommentThanksNotification { | |
id Int @id @default(autoincrement()) | |
thanksId Int | |
notificationId Int | |
thanks CommentThanks @relation(fields: [thanksId], references: [id], onDelete: Cascade) | |
notification InAppNotification @relation(fields: [notificationId], references: [id], onDelete: Cascade) | |
} | |
model ThreadCommentNotification { | |
id Int @id @default(autoincrement()) | |
notificationId Int | |
commentId Int | |
notification InAppNotification @relation(fields: [notificationId], references: [id], onDelete: Cascade) | |
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade) | |
} | |
model PostCommentNotification { | |
id Int @id @default(autoincrement()) | |
notificationId Int | |
postCommentId Int | |
notification InAppNotification @relation(fields: [notificationId], references: [id], onDelete: Cascade) | |
postComment PostComment @relation(fields: [postCommentId], references: [id], onDelete: Cascade) | |
} | |
model NewFollowerNotification { | |
id Int @id @default(autoincrement()) | |
notificationId Int | |
followingUserId Int | |
notification InAppNotification @relation(fields: [notificationId], references: [id], onDelete: Cascade) | |
followingUser User @relation(fields: [followingUserId], references: [id], onDelete: Cascade) | |
} | |
model PostClapNotification { | |
id Int @id @default(autoincrement()) | |
notificationId Int | |
postClapId Int | |
notification InAppNotification @relation(fields: [notificationId], references: [id], onDelete: Cascade) | |
postClap PostClap @relation(fields: [postClapId], references: [id], onDelete: Cascade) | |
} | |
model NewPostNotification { | |
id Int @id @default(autoincrement()) | |
notificationId Int | |
postId Int | |
notification InAppNotification @relation(fields: [notificationId], references: [id], onDelete: Cascade) | |
post Post @relation(fields: [postId], references: [id], onDelete: Cascade) | |
} | |
enum LanguageLevel { | |
BEGINNER | |
INTERMEDIATE | |
ADVANCED | |
NATIVE | |
} | |
enum UserRole { | |
ADMIN | |
MODERATOR | |
USER | |
} | |
enum PostStatus { | |
DRAFT | |
PUBLISHED | |
PRIVATE | |
} | |
enum UILanguage { | |
ENGLISH | |
GERMAN | |
SPANISH | |
} | |
enum BadgeType { | |
ALPHA_USER | |
BETA_USER | |
ONEHUNDRED_POSTS | |
TEN_POSTS | |
CODE_CONTRIBUTOR | |
ODRADEK | |
NECROMANCER | |
} | |
enum EmailNotificationType { | |
THREAD_COMMENT | |
POST_COMMENT | |
THREAD_COMMENT_THANKS | |
NEW_POST | |
POST_CLAP | |
} | |
enum InAppNotificationType { | |
THREAD_COMMENT | |
POST_COMMENT | |
THREAD_COMMENT_THANKS | |
NEW_POST | |
POST_CLAP | |
NEW_FOLLOWER | |
} | |
enum NotificationReadStatus { | |
READ | |
UNREAD | |
} | |
enum MembershipSubscriptionPeriod { | |
MONTHLY | |
QUARTERLY | |
ANNUALY | |
STUDENT_ANNUALLY | |
} | |
enum EmailVerificationStatus { | |
PENDING | |
VERIFIED | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment