-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.dbml
92 lines (74 loc) · 1.9 KB
/
db.dbml
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
// Use DBML to define your database structure
// Docs: https://dbml.dbdiagram.io/docs
Table refresh_token {
id int [primary key, increment]
user_id int
refresh_token varchar(255) [not null, unique]
access_token varchar(255) [not null, unique]
created_at timestamp [not null]
updated_at timestamp [not null]
deleted_at timestamp
}
Table user_data {
id int [primary key, increment]
name varchar(255) [not null]
email varchar(255) [not null]
hash varchar(255) [not null]
profile_picture_url varchar(255)
created_at timestamp [not null]
updated_at timestamp [not null]
deleted_at timestamp
indexes {
email [name: 'user_email_index']
}
}
Ref: refresh_token.user_id > user_data.id
Enum category_type_enum {
income
expense
}
Table category {
id int [primary key, increment]
name varchar(255) [not null, unique]
slug varchar(255) [not null,unique]
type category_type_enum
created_at timestamp [not null]
updated_at timestamp [not null]
deleted_at timestamp
indexes {
type [name: 'category_type_index']
}
}
Table subcategory {
id int [primary key, increment]
name varchar(255) [not null]
slug varchar(255) [not null,unique]
user_id int [not null]
category_id int [not null]
created_at timestamp [not null]
updated_at timestamp [not null]
deleted_at timestamp
}
Enum transaction_type_enum {
income
expense
}
Table transaction {
id int [primary key, increment]
created_at timestamp [not null]
updated_at timestamp [not null]
deleted_at timestamp
amount numeric(10,0) [not null]
description text
transaction_type transaction_type_enum [not null]
user_id int
category_id int
subcategory_id int
indexes {
transaction_type [name: 'transaction_type_index']
}
}
Ref: transaction.user_id > user_data.id
Ref: subcategory.user_id > user_data.id
Ref: subcategory.category_id > category.id
Ref: transaction.category_id - category.id