3
3
CREATE TABLE IF NOT EXISTS ` user`
4
4
(
5
5
id INTEGER PRIMARY KEY AUTOINCREMENT,
6
- created_on INTEGER NOT NULL DEFAULT 0 ,
7
- modified_on INTEGER NOT NULL DEFAULT 0 ,
6
+ created_at INTEGER NOT NULL DEFAULT 0 ,
7
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
8
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
8
9
name TEXT NOT NULL ,
9
10
nickname TEXT NOT NULL ,
10
11
email TEXT NOT NULL ,
11
12
is_system INTEGER NOT NULL DEFAULT 0 ,
12
- is_disabled INTEGER NOT NULL DEFAULT 0 ,
13
- is_deleted INTEGER NOT NULL DEFAULT 0
13
+ is_disabled INTEGER NOT NULL DEFAULT 0
14
14
);
15
15
16
16
CREATE TABLE IF NOT EXISTS ` capability`
17
17
(
18
- id INTEGER PRIMARY KEY AUTOINCREMENT,
19
- name TEXT NOT NULL ,
18
+ name TEXT PRIMARY KEY ,
20
19
UNIQUE (name)
21
20
);
22
21
23
22
CREATE TABLE IF NOT EXISTS ` user_has_capability`
24
23
(
25
24
user_id INTEGER NOT NULL ,
26
- capability_id INTEGER NOT NULL ,
27
- UNIQUE (user_id, capability_id ),
28
- FOREIGN KEY (capability_id ) REFERENCES capability (id )
25
+ capability_name TEXT NOT NULL ,
26
+ UNIQUE (user_id, capability_name ),
27
+ FOREIGN KEY (capability_name ) REFERENCES capability (name )
29
28
);
30
29
31
30
CREATE TABLE IF NOT EXISTS ` auth`
32
31
(
33
32
id INTEGER PRIMARY KEY AUTOINCREMENT,
34
- created_on INTEGER NOT NULL DEFAULT 0 ,
35
- modified_on INTEGER NOT NULL DEFAULT 0 ,
33
+ created_at INTEGER NOT NULL DEFAULT 0 ,
34
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
35
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
36
36
user_id INTEGER NOT NULL ,
37
37
type TEXT NOT NULL ,
38
38
secret TEXT NOT NULL ,
39
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
40
39
FOREIGN KEY (user_id) REFERENCES user (id),
41
40
UNIQUE (user_id, type)
42
41
);
43
42
44
43
CREATE TABLE IF NOT EXISTS ` setting`
45
44
(
46
45
id INTEGER PRIMARY KEY AUTOINCREMENT,
47
- created_on INTEGER NOT NULL DEFAULT 0 ,
48
- modified_on INTEGER NOT NULL DEFAULT 0 ,
46
+ created_at INTEGER NOT NULL DEFAULT 0 ,
47
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
48
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
49
49
name TEXT NOT NULL ,
50
50
description TEXT NOT NULL DEFAULT " " ,
51
51
value TEXT NOT NULL ,
@@ -55,8 +55,9 @@ CREATE TABLE IF NOT EXISTS `setting`
55
55
CREATE TABLE IF NOT EXISTS ` audit_log`
56
56
(
57
57
id INTEGER PRIMARY KEY AUTOINCREMENT,
58
- created_on INTEGER NOT NULL DEFAULT 0 ,
59
- modified_on INTEGER NOT NULL DEFAULT 0 ,
58
+ created_at INTEGER NOT NULL DEFAULT 0 ,
59
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
60
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
60
61
user_id INTEGER NOT NULL ,
61
62
object_type TEXT NOT NULL ,
62
63
object_id INTEGER NOT NULL ,
@@ -68,36 +69,37 @@ CREATE TABLE IF NOT EXISTS `audit_log`
68
69
CREATE TABLE IF NOT EXISTS ` certificate_authority`
69
70
(
70
71
id INTEGER PRIMARY KEY AUTOINCREMENT,
71
- created_on INTEGER NOT NULL DEFAULT 0 ,
72
- modified_on INTEGER NOT NULL DEFAULT 0 ,
72
+ created_at INTEGER NOT NULL DEFAULT 0 ,
73
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
74
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
73
75
name TEXT NOT NULL ,
74
76
acmesh_server TEXT NOT NULL DEFAULT " " ,
75
77
ca_bundle TEXT NOT NULL DEFAULT " " ,
76
78
is_wildcard_supported INTEGER NOT NULL DEFAULT 0 , -- specific to each CA, acme v1 doesn't usually have wildcards
77
79
max_domains INTEGER NOT NULL DEFAULT 5 , -- per request
78
- is_readonly INTEGER NOT NULL DEFAULT 0 ,
79
- is_deleted INTEGER NOT NULL DEFAULT 0
80
+ is_readonly INTEGER NOT NULL DEFAULT 0
80
81
);
81
82
82
83
CREATE TABLE IF NOT EXISTS ` dns_provider`
83
84
(
84
85
id INTEGER PRIMARY KEY AUTOINCREMENT,
85
- created_on INTEGER NOT NULL DEFAULT 0 ,
86
- modified_on INTEGER NOT NULL DEFAULT 0 ,
86
+ created_at INTEGER NOT NULL DEFAULT 0 ,
87
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
88
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
87
89
user_id INTEGER NOT NULL ,
88
90
name TEXT NOT NULL ,
89
91
acmesh_name TEXT NOT NULL ,
90
92
dns_sleep INTEGER NOT NULL DEFAULT 0 ,
91
93
meta TEXT NOT NULL ,
92
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
93
94
FOREIGN KEY (user_id) REFERENCES user (id)
94
95
);
95
96
96
97
CREATE TABLE IF NOT EXISTS ` certificate`
97
98
(
98
99
id INTEGER PRIMARY KEY AUTOINCREMENT,
99
- created_on INTEGER NOT NULL DEFAULT 0 ,
100
- modified_on INTEGER NOT NULL DEFAULT 0 ,
100
+ created_at INTEGER NOT NULL DEFAULT 0 ,
101
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
102
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
101
103
type TEXT NOT NULL , -- custom,dns,http
102
104
user_id INTEGER NOT NULL ,
103
105
certificate_authority_id INTEGER , -- 0 for a custom cert
@@ -109,7 +111,6 @@ CREATE TABLE IF NOT EXISTS `certificate`
109
111
error_message text NOT NULL DEFAULT " " ,
110
112
meta TEXT NOT NULL ,
111
113
is_ecc INTEGER NOT NULL DEFAULT 0 ,
112
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
113
114
FOREIGN KEY (user_id) REFERENCES user (id),
114
115
FOREIGN KEY (certificate_authority_id) REFERENCES certificate_authority (id),
115
116
FOREIGN KEY (dns_provider_id) REFERENCES dns_provider (id)
@@ -118,24 +119,25 @@ CREATE TABLE IF NOT EXISTS `certificate`
118
119
CREATE TABLE IF NOT EXISTS ` stream`
119
120
(
120
121
id INTEGER PRIMARY KEY AUTOINCREMENT,
121
- created_on INTEGER NOT NULL DEFAULT 0 ,
122
- modified_on INTEGER NOT NULL DEFAULT 0 ,
122
+ created_at INTEGER NOT NULL DEFAULT 0 ,
123
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
124
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
123
125
user_id INTEGER NOT NULL ,
124
126
listen_interface TEXT NOT NULL ,
125
127
incoming_port INTEGER NOT NULL ,
126
128
tcp_forwarding INTEGER NOT NULL DEFAULT 0 ,
127
129
udp_forwarding INTEGER NOT NULL DEFAULT 0 ,
128
130
advanced_config TEXT NOT NULL ,
129
131
is_disabled INTEGER NOT NULL DEFAULT 0 ,
130
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
131
132
FOREIGN KEY (user_id) REFERENCES user (id)
132
133
);
133
134
134
135
CREATE TABLE IF NOT EXISTS ` upstream`
135
136
(
136
137
id INTEGER PRIMARY KEY AUTOINCREMENT,
137
- created_on INTEGER NOT NULL DEFAULT 0 ,
138
- modified_on INTEGER NOT NULL DEFAULT 0 ,
138
+ created_at INTEGER NOT NULL DEFAULT 0 ,
139
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
140
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
139
141
user_id INTEGER NOT NULL ,
140
142
name TEXT NOT NULL ,
141
143
nginx_template_id INTEGER NOT NULL ,
@@ -148,57 +150,57 @@ CREATE TABLE IF NOT EXISTS `upstream`
148
150
advanced_config TEXT NOT NULL ,
149
151
status TEXT NOT NULL DEFAULT " " ,
150
152
error_message TEXT NOT NULL DEFAULT " " ,
151
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
152
153
FOREIGN KEY (user_id) REFERENCES user (id),
153
154
FOREIGN KEY (nginx_template_id) REFERENCES nginx_template (id)
154
155
);
155
156
156
157
CREATE TABLE IF NOT EXISTS ` upstream_server`
157
158
(
158
159
id INTEGER PRIMARY KEY AUTOINCREMENT,
159
- created_on INTEGER NOT NULL DEFAULT 0 ,
160
- modified_on INTEGER NOT NULL DEFAULT 0 ,
160
+ created_at INTEGER NOT NULL DEFAULT 0 ,
161
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
162
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
161
163
upstream_id INTEGER NOT NULL ,
162
164
server TEXT NOT NULL ,
163
165
weight INTEGER NOT NULL DEFAULT 0 ,
164
166
max_conns INTEGER NOT NULL DEFAULT 0 ,
165
167
max_fails INTEGER NOT NULL DEFAULT 0 ,
166
168
fail_timeout INTEGER NOT NULL DEFAULT 0 ,
167
- backup INTEGER NOT NULL DEFAULT 0 ,
168
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
169
+ is_backup INTEGER NOT NULL DEFAULT 0 ,
169
170
FOREIGN KEY (upstream_id) REFERENCES upstream (id)
170
171
);
171
172
172
173
CREATE TABLE IF NOT EXISTS ` access_list`
173
174
(
174
175
id INTEGER PRIMARY KEY AUTOINCREMENT,
175
- created_on INTEGER NOT NULL DEFAULT 0 ,
176
- modified_on INTEGER NOT NULL DEFAULT 0 ,
176
+ created_at INTEGER NOT NULL DEFAULT 0 ,
177
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
178
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
177
179
user_id INTEGER NOT NULL ,
178
180
name TEXT NOT NULL ,
179
181
meta TEXT NOT NULL ,
180
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
181
182
FOREIGN KEY (user_id) REFERENCES user (id)
182
183
);
183
184
184
185
CREATE TABLE IF NOT EXISTS ` nginx_template`
185
186
(
186
187
id INTEGER PRIMARY KEY AUTOINCREMENT,
187
- created_on INTEGER NOT NULL DEFAULT 0 ,
188
- modified_on INTEGER NOT NULL DEFAULT 0 ,
188
+ created_at INTEGER NOT NULL DEFAULT 0 ,
189
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
190
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
189
191
user_id INTEGER NOT NULL ,
190
192
name TEXT NOT NULL ,
191
193
type TEXT NOT NULL ,
192
194
template TEXT NOT NULL ,
193
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
194
195
FOREIGN KEY (user_id) REFERENCES user (id)
195
196
);
196
197
197
198
CREATE TABLE IF NOT EXISTS ` host`
198
199
(
199
200
id INTEGER PRIMARY KEY AUTOINCREMENT,
200
- created_on INTEGER NOT NULL DEFAULT 0 ,
201
- modified_on INTEGER NOT NULL DEFAULT 0 ,
201
+ created_at INTEGER NOT NULL DEFAULT 0 ,
202
+ updated_at INTEGER NOT NULL DEFAULT 0 ,
203
+ is_deleted INTEGER NOT NULL DEFAULT 0 ,
202
204
user_id INTEGER NOT NULL ,
203
205
type TEXT NOT NULL ,
204
206
nginx_template_id INTEGER NOT NULL ,
@@ -222,7 +224,6 @@ CREATE TABLE IF NOT EXISTS `host`
222
224
status TEXT NOT NULL DEFAULT " " ,
223
225
error_message TEXT NOT NULL DEFAULT " " ,
224
226
is_disabled INTEGER NOT NULL DEFAULT 0 ,
225
- is_deleted INTEGER NOT NULL DEFAULT 0 ,
226
227
FOREIGN KEY (user_id) REFERENCES user (id),
227
228
FOREIGN KEY (nginx_template_id) REFERENCES nginx_template (id),
228
229
FOREIGN KEY (upstream_id) REFERENCES upstream (id),
0 commit comments