@@ -28,7 +28,7 @@ CREATE TABLE "capability" (
28
28
29
29
CREATE TABLE "user_has_capability " (
30
30
" user_id" INTEGER NOT NULL ,
31
- " capability_name" TEXT NOT NULL REFERENCES " capability" (" name" ),
31
+ " capability_name" TEXT NOT NULL REFERENCES " capability" (" name" ) ON DELETE CASCADE ,
32
32
UNIQUE (" user_id" , " capability_name" )
33
33
);
34
34
@@ -37,7 +37,7 @@ CREATE TABLE "auth" (
37
37
" created_at" BIGINT NOT NULL DEFAULT 0 ,
38
38
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
39
39
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
40
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
40
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
41
41
" type" VARCHAR (50 ) NOT NULL ,
42
42
" secret" VARCHAR (255 ) NOT NULL ,
43
43
UNIQUE (" user_id" , " type" )
@@ -59,7 +59,7 @@ CREATE TABLE "audit_log" (
59
59
" created_at" BIGINT NOT NULL DEFAULT 0 ,
60
60
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
61
61
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
62
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
62
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
63
63
" object_type" VARCHAR (50 ) NOT NULL ,
64
64
" object_id" INTEGER NOT NULL ,
65
65
" action" VARCHAR (50 ) NOT NULL ,
@@ -84,7 +84,7 @@ CREATE TABLE "dns_provider" (
84
84
" created_at" BIGINT NOT NULL DEFAULT 0 ,
85
85
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
86
86
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
87
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
87
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
88
88
" name" VARCHAR (50 ) NOT NULL ,
89
89
" acmesh_name" VARCHAR (50 ) NOT NULL ,
90
90
" dns_sleep" INTEGER NOT NULL DEFAULT 0 ,
@@ -96,10 +96,10 @@ CREATE TABLE "certificate" (
96
96
" created_at" BIGINT NOT NULL DEFAULT 0 ,
97
97
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
98
98
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
99
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
99
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
100
100
" type" VARCHAR (50 ) NOT NULL , -- custom,dns,http
101
- " certificate_authority_id" INTEGER REFERENCES " certificate_authority" (" id" ), -- 0 for a custom cert
102
- " dns_provider_id" INTEGER REFERENCES " dns_provider" (" id" ), -- 0, for a http or custom cert
101
+ " certificate_authority_id" INTEGER REFERENCES " certificate_authority" (" id" ) ON DELETE CASCADE , -- 0 for a custom cert
102
+ " dns_provider_id" INTEGER REFERENCES " dns_provider" (" id" ) ON DELETE CASCADE , -- 0, for a http or custom cert
103
103
" name" VARCHAR (50 ) NOT NULL ,
104
104
" domain_names" TEXT NOT NULL ,
105
105
" expires_on" INTEGER DEFAULT 0 ,
@@ -114,7 +114,7 @@ CREATE TABLE "stream" (
114
114
" created_at" BIGINT NOT NULL DEFAULT 0 ,
115
115
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
116
116
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
117
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
117
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
118
118
" listen_interface" VARCHAR (50 ) NOT NULL ,
119
119
" incoming_port" INTEGER NOT NULL ,
120
120
" tcp_forwarding" INTEGER NOT NULL DEFAULT 0 ,
@@ -128,7 +128,7 @@ CREATE TABLE "nginx_template" (
128
128
" created_at" BIGINT NOT NULL DEFAULT 0 ,
129
129
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
130
130
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
131
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
131
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
132
132
" name" VARCHAR (50 ) NOT NULL ,
133
133
" type" VARCHAR (50 ) NOT NULL ,
134
134
" template" TEXT NOT NULL
@@ -141,7 +141,7 @@ CREATE TABLE "upstream" (
141
141
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
142
142
" user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
143
143
" name" VARCHAR (50 ) NOT NULL ,
144
- " nginx_template_id" INTEGER NOT NULL REFERENCES " nginx_template" (" id" ),
144
+ " nginx_template_id" INTEGER NOT NULL REFERENCES " nginx_template" (" id" ) ON DELETE CASCADE ,
145
145
" ip_hash" BOOLEAN NOT NULL DEFAULT FALSE,
146
146
" ntlm" BOOLEAN NOT NULL DEFAULT FALSE,
147
147
" keepalive" INTEGER NOT NULL DEFAULT 0 ,
@@ -158,7 +158,7 @@ CREATE TABLE "upstream_server" (
158
158
" created_at" BIGINT NOT NULL DEFAULT 0 ,
159
159
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
160
160
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
161
- " upstream_id" INTEGER NOT NULL REFERENCES " upstream" (" id" ),
161
+ " upstream_id" INTEGER NOT NULL REFERENCES " upstream" (" id" ) ON DELETE CASCADE ,
162
162
" server" VARCHAR (50 ) NOT NULL ,
163
163
" weight" INTEGER NOT NULL DEFAULT 0 ,
164
164
" max_conns" INTEGER NOT NULL DEFAULT 0 ,
@@ -172,7 +172,7 @@ CREATE TABLE "access_list" (
172
172
" created_at" BIGINT NOT NULL DEFAULT 0 ,
173
173
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
174
174
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
175
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
175
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
176
176
" name" VARCHAR (50 ) NOT NULL ,
177
177
" meta" TEXT NOT NULL
178
178
);
@@ -182,17 +182,17 @@ CREATE TABLE "host" (
182
182
" created_at" BIGINT NOT NULL DEFAULT 0 ,
183
183
" updated_at" BIGINT NOT NULL DEFAULT 0 ,
184
184
" is_deleted" INTEGER NOT NULL DEFAULT 0 , -- int on purpose, gormism
185
- " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ),
185
+ " user_id" INTEGER NOT NULL REFERENCES " user" (" id" ) ON DELETE CASCADE ,
186
186
" type" TEXT NOT NULL ,
187
- " nginx_template_id" INTEGER NOT NULL REFERENCES " nginx_template" (" id" ),
187
+ " nginx_template_id" INTEGER NOT NULL REFERENCES " nginx_template" (" id" ) ON DELETE CASCADE ,
188
188
" listen_interface" TEXT NOT NULL DEFAULT ' ' ,
189
189
" domain_names" TEXT NOT NULL ,
190
- " upstream_id" INTEGER NOT NULL DEFAULT 0 REFERENCES " upstream" (" id" ),
190
+ " upstream_id" INTEGER NOT NULL DEFAULT 0 REFERENCES " upstream" (" id" ) ON DELETE CASCADE ,
191
191
" proxy_scheme" TEXT NOT NULL DEFAULT ' ' ,
192
192
" proxy_host" TEXT NOT NULL DEFAULT ' ' ,
193
193
" proxy_port" INTEGER NOT NULL DEFAULT 0 ,
194
- " certificate_id" INTEGER NOT NULL DEFAULT 0 REFERENCES " certificate" (" id" ),
195
- " access_list_id" INTEGER NOT NULL DEFAULT 0 REFERENCES " access_list" (" id" ),
194
+ " certificate_id" INTEGER NOT NULL DEFAULT 0 REFERENCES " certificate" (" id" ) ON DELETE CASCADE ,
195
+ " access_list_id" INTEGER NOT NULL DEFAULT 0 REFERENCES " access_list" (" id" ) ON DELETE CASCADE ,
196
196
" ssl_forced" BOOLEAN NOT NULL DEFAULT FALSE,
197
197
" caching_enabled" BOOLEAN NOT NULL DEFAULT FALSE,
198
198
" block_exploits" BOOLEAN NOT NULL DEFAULT FALSE,
0 commit comments