-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
schema.prisma
62 lines (51 loc) · 1.38 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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
generator dbml {
provider = "node ./dist/generator.js"
mapToDbSchema = "false"
}
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @db.DateTime(0)
updatedAt DateTime @updatedAt @map("updated_at")
email String @unique
name String? @db.VarChar(255)
posts Post[]
profile Profile?
@@map("user")
}
/// User profile
model Profile {
id Int @id @default(autoincrement())
bio String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
userId Int @unique
@@map("profile")
}
model Post {
id Int @id @default(autoincrement())
title String @default("")
content String?
published Boolean @default(false)
author User? @relation(fields: [authorId], references: [id], onDelete: SetNull)
authorId Int?
categories Category[]
}
model Category {
id Int @id @default(autoincrement())
name String
posts Post[]
}
model Token {
id Int @id @default(autoincrement())
device String
operatingSystem String
@@unique([device, operatingSystem])
}