-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sql
124 lines (115 loc) · 1.95 KB
/
setup.sql
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
-- name: create-smart-chef
create table Ingredient
(
id integer
primary key
autoincrement,
name varchar,
created_at datetime default CURRENT_TIMESTAMP
)
;
create unique index Ingredient_name_uindex
on Ingredient (name)
;
create table Recipe
(
id integer
primary key
autoincrement,
title varchar,
created_at datetime default CURRENT_TIMESTAMP
)
;
create table Step
(
id integer
primary key
autoincrement,
recipe_fk integer
constraint recipe_fk
references Recipe,
data varchar,
created_at datetime default CURRENT_TIMESTAMP,
step_number integer
)
;
create table Step_Ingredient
(
id integer not null
primary key
autoincrement,
quantity float,
unit varchar,
created_at datetime default CURRENT_TIMESTAMP,
step_fk int
constraint step__fk
references Step,
ingredient_fk int
constraint ingredient__fk
references Ingredient
)
;
create table Trigger_Group
(
id integer
primary key
autoincrement,
step_fk integer
constraint step__fk
references Step,
action_key varchar,
service varchar,
action_params varchar
)
;
create table Trigger_Type
(
id integer
primary key
autoincrement,
created_at datetime default CURRENT_TIMESTAMP,
key varchar,
sensor_type varchar
)
;
create table Trigger
(
id integer
primary key
autoincrement,
tigger_type_fk integer
constraint trigger_type__fk
references Trigger_Type,
service varchar,
created_at datetime default CURRENT_TIMESTAMP,
action_params varchar,
action varchar,
trigger_params varchar,
trigger_group_fk integer
constraint trigger_group__fk
references Trigger_Group
)
;
create table Utensil
(
id integer
primary key
autoincrement,
name varchar,
created_at datetime default CURRENT_TIMESTAMP
)
;
create table Step_Utensil
(
id integer not null
primary key
autoincrement,
utensil_fk int
constraint utensil__fk
references Utensil,
step_fk int
constraint step__fk
references Step,
created_at datetime default CURRENT_TIMESTAMP
)
;