generated from notiz-dev/nestjs-prisma-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
48 lines (41 loc) · 1.22 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
generator client {
provider = "prisma-client-js"
}
generator dbml {
provider = "prisma-dbml-generator"
}
datasource db {
provider = "mysql"
url = env("DB_URL")
}
// I like to keep the database design as independent from any ORM/framework as
// possible. Therefore, I use some database specific features (vs. Prisma)
// like timestamp columns, auto increment IDs, etc. I also map table and column
// names to lower case letters with underscores.
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
email String @unique
password String
firstname String?
lastname String?
role Role @default(USER)
posts Post[]
@@map("users")
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
published Boolean
title String
content String
authorId Int @map("author_id")
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
@@map("posts")
}
enum Role {
ADMIN
USER
}