Files
landscape-template/prisma/schema.prisma
2022-07-20 18:36:51 +03:00

219 lines
4.7 KiB
Plaintext

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// -----------------
// Shared
// -----------------
model Tag {
id Int @id @default(autoincrement())
title String @unique
icon String?
description String?
isOfficial Boolean @default(false)
project Project[]
stories Story[]
questions Question[]
hackathons Hackathon[]
}
model Vote {
id Int @id @default(autoincrement())
item_id Int
item_type String
amount_in_sat Int
payment_request String?
payment_hash String?
preimage String?
paid Boolean @default(false)
}
// -----------------
// Users
// -----------------
model User {
id Int @id @default(autoincrement())
pubKey String? @unique
name String?
avatar String?
role String @default("user")
email String?
jobTitle String?
lightning_address String?
website String?
twitter String?
github String?
linkedin String?
bio String?
location String?
nostr_prv_key String?
nostr_pub_key String?
join_date DateTime @default(now())
stories Story[]
questions Question[]
posts_comments PostComment[]
donations Donation[]
}
// -----------------
// Projects
// -----------------
model Category {
id Int @id @default(autoincrement())
title String
cover_image String?
icon String?
project Project[]
}
model Project {
id Int @id @default(autoincrement())
title String
description String
screenshots String[]
website String
thumbnail_image String?
cover_image String?
lightning_address String?
lnurl_callback_url String?
category Category @relation(fields: [category_id], references: [id])
category_id Int
votes_count Int @default(0)
createdAt DateTime @default(now())
awards Award[]
tags Tag[]
}
model Award {
id Int @id @default(autoincrement())
title String
image String
url String
project Project @relation(fields: [project_id], references: [id])
project_id Int
}
// -----------------
// Posts
// -----------------
model Story {
id Int @id @default(autoincrement())
title String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
body String
excerpt String
cover_image String?
votes_count Int @default(0)
is_published Boolean @default(true)
tags Tag[]
user User? @relation(fields: [user_id], references: [id])
user_id Int?
comments PostComment[] @relation("StoryComment")
}
model Question {
id Int @id @default(autoincrement())
title String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
body String
excerpt String
votes_count Int @default(0)
is_published Boolean @default(true)
tags Tag[]
user User? @relation(fields: [user_id], references: [id])
user_id Int?
comments PostComment[] @relation("QuestionComment")
}
model PostComment {
id Int @id @default(autoincrement())
body String
created_at DateTime @default(now())
votes_count Int @default(0)
replies PostComment[] @relation("PostComment_Replies")
parent_comment_id Int?
parent_comment PostComment? @relation("PostComment_Replies", fields: [parent_comment_id], references: [id])
user User? @relation(fields: [user_id], references: [id])
user_id Int?
story Story? @relation("StoryComment", fields: [story_id], references: [id])
story_id Int?
question Question? @relation("QuestionComment", fields: [question_id], references: [id])
question_id Int?
}
// -----------------
// Hackathons
// -----------------
model Hackathon {
id Int @id @default(autoincrement())
title String
start_date DateTime @db.Date
end_date DateTime @db.Date
cover_image String
description String
location String
website String
votes_count Int @default(0)
tags Tag[]
}
// -----------------
// Donations
// -----------------
model Donation {
id Int @id @default(autoincrement())
amount Int
createdAt DateTime @default(now()) @db.Date
payment_request String?
payment_hash String?
preimage String?
paid Boolean @default(false)
donor User? @relation(fields: [donor_id], references: [id])
donor_id Int?
}
// -----------------
// Auth
// -----------------
model GeneratedK1 {
value String @id
sid String?
createdAt DateTime @default(now())
}