-
Notifications
You must be signed in to change notification settings - Fork 3
/
schema.prisma
113 lines (97 loc) · 3.1 KB
/
schema.prisma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// --------------------------------------
model User {
bio String?
email String @unique
id Int @id @default(autoincrement())
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String?
hashedPassword String?
username String? @unique
articles Article[] @relation("UserArticles")
favorites Article[] @relation("UserFavorites", references: [id])
comments Comment[] @relation("UserComments")
followedBy User[] @relation("UserFollows", references: [id])
following User[] @relation("UserFollows", references: [id])
role String @default("USER")
tokens Token[]
sessions Session[]
}
model Session {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
expiresAt DateTime?
handle String @unique
hashedSessionToken String?
antiCSRFToken String?
publicData String?
privateData String?
user User? @relation(fields: [userId], references: [id])
userId Int?
}
model Token {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
hashedToken String
type String
// See note below about TokenType enum
// type TokenType
expiresAt DateTime
sentTo String
user User @relation(fields: [userId], references: [id])
userId Int
@@unique([hashedToken, type])
}
// NOTE: It's highly recommended to use an enum for the token type
// but enums only work in Postgres.
// See: https://blitzjs.com/docs/database-overview#switch-to-postgresql
// enum TokenType {
// RESET_PASSWORD
// }
model Project {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
}
// From RealWorld, plus User merged above
model Article {
id Int @default(autoincrement()) @id
slug String @unique
title String
description String
body String
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
tagList String
author User @relation("UserArticles", fields: [authorId], references: [id])
authorId Int
favoritedBy User[] @relation("UserFavorites", references: [id])
comments Comment[]
}
model Comment {
id Int @default(autoincrement()) @id
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
body String
article Article @relation(fields: [articleId], references: [id])
articleId Int
author User @relation("UserComments", fields: [authorId], references: [id])
authorId Int
}
model Tag {
id Int @default(autoincrement()) @id
name String @unique
}