PronounsPage/new/backend/prisma/schema.prisma
tecc 5e3c287e51
feat(rewrite): Users, tokens, authentication, etc.
This is essentially a codedump because there are too many interweaved changes for me to keep track of or separate into smaller, more comprehensible commits.
So, enjoy! This maelstrom of code, torrent of implementations, and other minor changes.
2024-04-17 05:10:02 +02:00

352 lines
10 KiB
Plaintext

generator client {
provider = "prisma-client-js"
output = "dist"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model OldAuditLog {
id String @id
userId String?
username String?
event String
payload String?
@@map("audit_log")
}
model NewAuditLog {
id Int @id @default(autoincrement())
loggedAt Int
locale String?
entryType String
entryData String
meta AuditLogEntryMeta[]
@@map("audit_logs_new")
}
model AuditLogEntryMeta {
entryId Int
entry NewAuditLog @relation(fields: [entryId], references: [id])
time Int
type String
value String
@@unique([entryId, type, value])
@@map("audit_log_entry_meta")
}
model Authenticator {
id String @id
userId String?
type String
payload String
validUntil Int?
user User? @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@index([userId], map: "authenticators_userId")
@@index([type], map: "authenticators_type")
@@map("authenticators")
}
// Some manual changes here:
// 1. `bannedBy` is a nullable
model BanProposal {
id String @id
userId String
bannedBy String?
bannedTerms String
bannedReason String
bannedByUser User? @relation("ban_proposals_bannedByTousers", fields: [bannedBy], references: [id], onDelete: SetNull, onUpdate: NoAction)
user User @relation("ban_proposals_userIdTousers", fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@index([userId], map: "ban_proposals_userId")
@@map("ban_proposals")
}
model Ban {
type String
value String
@@id([type, value])
@@map("ban")
}
model Inclusive {
id String @id
insteadOf String
say String
because String
locale String
approved Int
base_id String?
author_id String?
categories String?
links String?
deleted Int @default(0)
clarification String?
users User? @relation(fields: [author_id], references: [id], onUpdate: NoAction)
@@index([insteadOf], map: "inclusive_insteadOf")
@@index([locale], map: "inclusive_locale")
@@map("inclusive")
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
model Link {
url String? @id
expiresAt Int?
favicon String?
relMe String?
nodeinfo String?
@@map("links")
@@ignore
}
model Name {
id String @id
name String
locale String
origin String?
meaning String?
usage String?
legally String?
pros String?
cons String?
notablePeople String?
links String?
namedays String?
namedaysComment String?
deleted Int @default(0)
approved Int @default(0)
base_id String?
author_id String?
@@index([locale], map: "names_locale")
@@index([name], map: "names_name")
@@index([locale, name], map: "names_name_locale")
@@map("names")
}
model Noun {
id String @id
masc String
fem String
neutr String
mascPl String
femPl String
neutrPl String
approved Int
base_id String?
locale String @default("pl")
author_id String?
deleted Int @default(0)
sources String?
users User? @relation(fields: [author_id], references: [id], onUpdate: NoAction)
@@index([masc], map: "nouns_masc")
@@index([locale], map: "nouns_locale")
@@map("nouns")
}
model Profile {
id String @id
userId String
locale String
names String
pronouns String
description String
birthday String?
links String
flags String
words String
active Int
teamName String?
footerName String?
footerAreas String?
customFlags String @default("{}")
card String?
credentials String?
credentialsLevel Int?
credentialsName Int?
cardDark String?
opinions String @default("{}")
timezone String?
sensitive String @default("[]")
users User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
user_connections UserConnection[]
@@unique([userId, locale], map: "sqlite_autoindex_profiles_2")
@@index([footerAreas], map: "profiles_footerAreas")
@@index([footerName], map: "profiles_footerName")
@@index([teamName], map: "profiles_teamName")
@@index([locale, userId], map: "profiles_locale_userId")
@@index([userId], map: "profiles_userId")
@@index([locale], map: "profiles_locale")
@@map("profiles")
}
model Report {
id String @id
userId String?
reporterId String?
comment String
isAutomatic Int?
isHandled Int?
snapshot String?
users_reports_reporterIdTousers User? @relation("reports_reporterIdTousers", fields: [reporterId], references: [id], onUpdate: NoAction)
users_reports_userIdTousers User? @relation("reports_userIdTousers", fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@index([userId], map: "reports_userId")
@@index([isHandled], map: "reports_isHandled")
@@index([isAutomatic], map: "reports_isAutomatic")
@@map("reports")
}
model SocialLookup {
userId String
provider String
identifier String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@unique([userId, provider, identifier])
@@index([provider, identifier], map: "social_lookup_provider_identifier")
@@map("social_lookup")
}
model Source {
id String @id
locale String
pronouns String
type String
author String?
title String
extra String?
year Int?
fragments String
comment String?
link String?
submitter_id String?
approved Int? @default(0)
deleted Int? @default(0)
base_id String?
key String?
images String?
spoiler Int @default(0)
users User? @relation(fields: [submitter_id], references: [id], onUpdate: NoAction)
@@index([locale], map: "sources_locale")
@@map("sources")
}
model Stat {
id String
locale String
users Int
data String
@@id([id, locale])
@@map("stats")
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
model SubscriptionMessage {
id String? @id
subscription_id String
campaign String
@@map("subscription_messages")
@@ignore
}
model Term {
id String @id
term String
original String?
definition String
locale String
approved Int
base_id String?
author_id String?
deleted Int @default(0)
flags String @default("[]")
category String?
images String @default("")
key String?
users User? @relation(fields: [author_id], references: [id], onUpdate: NoAction)
@@index([term], map: "terms_term")
@@index([locale], map: "terms_locale")
@@map("terms")
}
model UserConnection {
id String @id
from_profileId String
to_userId String
relationship String
users User @relation(fields: [to_userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
profiles Profile @relation(fields: [from_profileId], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@index([to_userId], map: "user_connections_to_userId")
@@index([from_profileId], map: "user_connections_from_profileId")
@@map("user_connections")
}
model UserMessage {
id String @id
userId String
adminId String
message String
@@map("user_messages")
}
model User {
id String @id
username String @unique(map: "users_username")
email String @unique(map: "users_email")
roles String
avatarSource String?
bannedReason String?
suspiciousChecked Unsupported("tinyint") @default(dbgenerated("0"))
usernameNorm String? @unique(map: "users_usernameNorm")
bannedTerms String?
bannedBy String?
lastActive Int?
banSnapshot String?
inactiveWarning Int?
adminNotifications Int @default(7)
loginAttempts String?
timesheets String?
socialLookup Int @default(0)
authenticators Authenticator[]
ban_proposals_ban_proposals_bannedByTousers BanProposal[] @relation("ban_proposals_bannedByTousers")
ban_proposals_ban_proposals_userIdTousers BanProposal[] @relation("ban_proposals_userIdTousers")
inclusive Inclusive[]
nouns Noun[]
profiles Profile[]
reports_reports_reporterIdTousers Report[] @relation("reports_reporterIdTousers")
reports_reports_userIdTousers Report[] @relation("reports_userIdTousers")
social_lookup SocialLookup[] @ignore
sources Source[]
terms Term[]
user_connections UserConnection[]
@@map("users")
}
model Email {
email String
sentAt Int
@@unique([email, sentAt])
@@index(fields: [email], map: "emails_email")
@@map("emails")
}