-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_schema.dbml
101 lines (81 loc) · 1.58 KB
/
test_schema.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Project test_schema {
author: 'dbml.org'
note: 'This schema is used for PyDBML doctest'
}
Enum "orders_status" {
"created"
"running"
"done"
"failure"
}
Enum "product status" {
"Out of Stock"
"In Stock"
}
Table "orders" [headercolor: #fff] {
"id" int [pk, increment]
"user_id" int [unique, not null]
"status" orders_status
"created_at" varchar
}
Table "order_items" {
"order_id" int
"product_id" int
"quantity" int [default: 1]
}
Table "products" {
"id" int [pk]
"name" varchar
"merchant_id" int [not null]
"price" int
"status" "product status"
"created_at" datetime [default: `now()`]
Indexes {
(merchant_id, status) [name: "product_status"]
id [type: hash, unique]
}
}
Table "users" {
"id" int [pk]
"full_name" varchar
"email" varchar [unique]
"gender" varchar
"date_of_birth" varchar
"created_at" varchar
"country_code" int
}
Ref:"orders"."id" < "order_items"."order_id"
TableGroup g1 {
users
merchants
}
TableGroup g2 {
countries
orders
}
Table "merchants" {
"id" int [pk]
"merchant_name" varchar
"country_code" int
"created_at" varchar
"admin_id" int
}
Ref:"products"."id" < "order_items"."product_id" [update: set default, delete: set null]
Ref:"countries"."code" < "users"."country_code"
Ref:"countries"."code" < "merchants"."country_code"
Ref:"merchants"."id" < "products"."merchant_id"
Ref:"users"."id" < "merchants"."admin_id"
Table "countries" {
"code" int [pk]
"name" varchar
"continent_name" varchar
}
Note sticky_note1 {
'One line note'
}
Note sticky_note2 {
'''
# Title
body
'''
}