-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrating.ts
42 lines (40 loc) · 882 Bytes
/
rating.ts
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
import { Table } from "@ghom/orm"
export interface Rating {
to_id: number
from_id: number
guild_id: number
value: 0 | 1 | 2 | 3 | 4 | 5
}
export default new Table<Rating>({
name: "note",
description: "Rating of a user by another user",
migrations: {
1: (table) => {
table.renameColumn("to", "to_id")
table.renameColumn("from", "from_id")
},
2: (table) => {
table
.integer("guild_id")
.references("_id")
.inTable("guild")
.onDelete("CASCADE")
.nullable()
},
},
setup: (table) => {
table
.integer("to")
.references("_id")
.inTable("user")
.onDelete("CASCADE")
.notNullable()
table
.integer("from")
.references("_id")
.inTable("user")
.onDelete("CASCADE")
.notNullable()
table.integer("value", 1).notNullable()
},
})