mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-01-22 21:08:13 -05:00
Fix inconsistencies between int and bool in db
This commit is contained in:
parent
7edcb8e3cc
commit
98ff4a7dcc
@ -69,8 +69,8 @@ func checkSetup() {
|
||||
|
||||
if db != nil {
|
||||
db.Model(&user.Model{}).
|
||||
Where("is_disabled = ?", 0).
|
||||
Where("is_system = ?", 0).
|
||||
Where("is_disabled = ?", false).
|
||||
Where("is_system = ?", false).
|
||||
Count(&count)
|
||||
|
||||
if count == 0 {
|
||||
|
@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `jwt_keys`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`public_key` TEXT NOT NULL,
|
||||
`private_key` TEXT NOT NULL
|
||||
);
|
||||
@ -15,12 +15,12 @@ CREATE TABLE IF NOT EXISTS `user`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`nickname` VARCHAR(50) NOT NULL,
|
||||
`email` VARCHAR(255) NOT NULL,
|
||||
`is_system` INT NOT NULL DEFAULT 0,
|
||||
`is_disabled` INT NOT NULL DEFAULT 0
|
||||
`is_system` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`is_disabled` BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `capability`
|
||||
@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS `auth`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`type` VARCHAR(50) NOT NULL,
|
||||
`secret` VARCHAR(255) NOT NULL,
|
||||
@ -55,7 +55,7 @@ CREATE TABLE IF NOT EXISTS `setting`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`value` TEXT NOT NULL,
|
||||
@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS `audit_log`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`object_type` VARCHAR(50) NOT NULL,
|
||||
`object_id` INT NOT NULL,
|
||||
@ -81,13 +81,13 @@ CREATE TABLE IF NOT EXISTS `certificate_authority`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`acmesh_server` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ca_bundle` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`is_wildcard_supported` INT NOT NULL DEFAULT 0, -- specific to each CA, acme v1 doesn't usually have wildcards
|
||||
`is_wildcard_supported` BOOLEAN NOT NULL DEFAULT FALSE, -- specific to each CA, acme v1 doesn't usually have wildcards
|
||||
`max_domains` INT NOT NULL DEFAULT 5, -- per request
|
||||
`is_readonly` INT NOT NULL DEFAULT 0
|
||||
`is_readonly` BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dns_provider`
|
||||
@ -95,7 +95,7 @@ CREATE TABLE IF NOT EXISTS `dns_provider`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`acmesh_name` VARCHAR(50) NOT NULL,
|
||||
@ -109,7 +109,7 @@ CREATE TABLE IF NOT EXISTS certificate
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`type` VARCHAR(50) NOT NULL, -- custom,dns,http
|
||||
`certificate_authority_id` INT, -- 0 for a custom cert
|
||||
@ -120,7 +120,7 @@ CREATE TABLE IF NOT EXISTS certificate
|
||||
`status` VARCHAR(50) NOT NULL, -- ready,requesting,failed,provided
|
||||
`error_message` TEXT NOT NULL,
|
||||
`meta` TEXT NOT NULL,
|
||||
`is_ecc` INT NOT NULL DEFAULT 0,
|
||||
`is_ecc` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`),
|
||||
FOREIGN KEY (`certificate_authority_id`) REFERENCES `certificate_authority`(`id`),
|
||||
FOREIGN KEY (`dns_provider_id`) REFERENCES `dns_provider`(`id`)
|
||||
@ -131,14 +131,14 @@ CREATE TABLE IF NOT EXISTS `stream`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`listen_interface` VARCHAR(50) NOT NULL,
|
||||
`incoming_port` INT NOT NULL,
|
||||
`tcp_forwarding` INT NOT NULL DEFAULT 0,
|
||||
`udp_forwarding` INT NOT NULL DEFAULT 0,
|
||||
`advanced_config` TEXT NOT NULL,
|
||||
`is_disabled` INT NOT NULL DEFAULT 0,
|
||||
`is_disabled` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`)
|
||||
);
|
||||
|
||||
@ -147,7 +147,7 @@ CREATE TABLE IF NOT EXISTS `nginx_template`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`type` VARCHAR(50) NOT NULL,
|
||||
@ -160,12 +160,12 @@ CREATE TABLE IF NOT EXISTS `upstream`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`nginx_template_id` INT NOT NULL,
|
||||
`ip_hash` INT NOT NULL DEFAULT 0,
|
||||
`ntlm` INT NOT NULL DEFAULT 0,
|
||||
`ip_hash` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`ntlm` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`keepalive` INT NOT NULL DEFAULT 0,
|
||||
`keepalive_requests` INT NOT NULL DEFAULT 0,
|
||||
`keepalive_time` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
@ -182,14 +182,14 @@ CREATE TABLE IF NOT EXISTS `upstream_server`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`upstream_id` INT NOT NULL,
|
||||
`server` VARCHAR(50) NOT NULL,
|
||||
`weight` INT NOT NULL DEFAULT 0,
|
||||
`max_conns` INT NOT NULL DEFAULT 0,
|
||||
`max_fails` INT NOT NULL DEFAULT 0,
|
||||
`fail_timeout` INT NOT NULL DEFAULT 0,
|
||||
`is_backup` INT NOT NULL DEFAULT 0,
|
||||
`is_backup` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
FOREIGN KEY (`upstream_id`) REFERENCES `upstream`(`id`)
|
||||
);
|
||||
|
||||
@ -198,7 +198,7 @@ CREATE TABLE IF NOT EXISTS `access_list`
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`meta` TEXT NOT NULL,
|
||||
@ -210,7 +210,7 @@ CREATE TABLE IF NOT EXISTS host
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`created_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`updated_at` BIGINT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
`user_id` INT NOT NULL,
|
||||
`type` VARCHAR(50) NOT NULL,
|
||||
`nginx_template_id` INT NOT NULL,
|
||||
@ -222,18 +222,18 @@ CREATE TABLE IF NOT EXISTS host
|
||||
`proxy_port` INT NOT NULL DEFAULT 0,
|
||||
`certificate_id` INT NOT NULL DEFAULT 0,
|
||||
`access_list_id` INT NOT NULL DEFAULT 0,
|
||||
`ssl_forced` INT NOT NULL DEFAULT 0,
|
||||
`caching_enabled` INT NOT NULL DEFAULT 0,
|
||||
`block_exploits` INT NOT NULL DEFAULT 0,
|
||||
`allow_websocket_upgrade` INT NOT NULL DEFAULT 0,
|
||||
`http2_support` INT NOT NULL DEFAULT 0,
|
||||
`hsts_enabled` INT NOT NULL DEFAULT 0,
|
||||
`hsts_subdomains` INT NOT NULL DEFAULT 0,
|
||||
`ssl_forced` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`caching_enabled` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`block_exploits` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`allow_websocket_upgrade` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`http2_support` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`hsts_enabled` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`hsts_subdomains` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`paths` TEXT NOT NULL,
|
||||
`advanced_config` TEXT NOT NULL,
|
||||
`status` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`error_message` TEXT NOT NULL,
|
||||
`is_disabled` INT NOT NULL DEFAULT 0,
|
||||
`is_disabled` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`),
|
||||
FOREIGN KEY (`nginx_template_id`) REFERENCES `nginx_template`(`id`),
|
||||
FOREIGN KEY (`upstream_id`) REFERENCES `upstream`(`id`),
|
||||
|
@ -1,8 +1,8 @@
|
||||
-- migrate:up
|
||||
|
||||
-- User permissions
|
||||
INSERT INTO capability (
|
||||
name
|
||||
INSERT INTO `capability` (
|
||||
`name`
|
||||
) VALUES
|
||||
("full-admin"),
|
||||
("access-lists.view"),
|
||||
@ -23,29 +23,23 @@ INSERT INTO capability (
|
||||
("streams.manage"),
|
||||
("users.manage");
|
||||
|
||||
INSERT INTO `setting` (
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`name`,
|
||||
`description`,
|
||||
`value`
|
||||
) VALUES
|
||||
-- Default error reporting setting
|
||||
INSERT INTO setting (
|
||||
created_at,
|
||||
updated_at,
|
||||
name,
|
||||
description,
|
||||
value
|
||||
) VALUES (
|
||||
(
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"error-reporting",
|
||||
"If enabled, any application errors are reported to Sentry. Sensitive information is not sent.",
|
||||
"true" -- remember this is json
|
||||
);
|
||||
|
||||
),
|
||||
-- Default site
|
||||
INSERT INTO setting (
|
||||
created_at,
|
||||
updated_at,
|
||||
name,
|
||||
description,
|
||||
value
|
||||
) VALUES (
|
||||
(
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"default-site",
|
||||
@ -55,93 +49,93 @@ INSERT INTO setting (
|
||||
|
||||
-- Default Certificate Authorities
|
||||
|
||||
INSERT INTO certificate_authority (
|
||||
created_at,
|
||||
updated_at,
|
||||
name,
|
||||
acmesh_server,
|
||||
is_wildcard_supported,
|
||||
max_domains,
|
||||
is_readonly
|
||||
INSERT INTO `certificate_authority` (
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`name`,
|
||||
`acmesh_server`,
|
||||
`is_wildcard_supported`,
|
||||
`max_domains`,
|
||||
`is_readonly`
|
||||
) VALUES (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"ZeroSSL",
|
||||
"zerossl",
|
||||
1,
|
||||
TRUE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"Let's Encrypt",
|
||||
"https://acme-v02.api.letsencrypt.org/directory",
|
||||
1,
|
||||
TRUE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"Buypass Go SSL",
|
||||
"https://api.buypass.com/acme/directory",
|
||||
0,
|
||||
FALSE,
|
||||
5,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"SSL.com",
|
||||
"ssl.com",
|
||||
0,
|
||||
FALSE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"Let's Encrypt (Testing)",
|
||||
"https://acme-staging-v02.api.letsencrypt.org/directory",
|
||||
1,
|
||||
TRUE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"Buypass Go SSL (Testing)",
|
||||
"https://api.test4.buypass.no/acme/directory",
|
||||
0,
|
||||
FALSE,
|
||||
5,
|
||||
1
|
||||
TRUE
|
||||
);
|
||||
|
||||
-- System User
|
||||
INSERT INTO user (
|
||||
created_at,
|
||||
updated_at,
|
||||
name,
|
||||
nickname,
|
||||
email,
|
||||
is_system
|
||||
INSERT INTO `user` (
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`name`,
|
||||
`nickname`,
|
||||
`email`,
|
||||
`is_system`
|
||||
) VALUES (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
"System",
|
||||
"System",
|
||||
"system@localhost",
|
||||
1
|
||||
TRUE
|
||||
);
|
||||
|
||||
-- Host Templates
|
||||
INSERT INTO nginx_template (
|
||||
created_at,
|
||||
updated_at,
|
||||
user_id,
|
||||
name,
|
||||
type,
|
||||
template
|
||||
INSERT INTO `nginx_template` (
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`user_id`,
|
||||
`name`,
|
||||
`type`,
|
||||
`template`
|
||||
) VALUES (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
(SELECT `id` FROM `user` WHERE `is_system` IS TRUE LIMIT 1),
|
||||
"Default Proxy Template",
|
||||
"proxy",
|
||||
"# ------------------------------------------------------------
|
||||
@ -264,28 +258,28 @@ server {
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
(SELECT `id` FROM `user` WHERE `is_system` IS TRUE LIMIT 1),
|
||||
"Default Redirect Template",
|
||||
"redirect",
|
||||
"# this is a redirect template"
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
(SELECT `id` FROM `user` WHERE `is_system` IS TRUE LIMIT 1),
|
||||
"Default Dead Template",
|
||||
"dead",
|
||||
"# this is a dead template"
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
(SELECT `id` FROM `user` WHERE `is_system` IS TRUE LIMIT 1),
|
||||
"Default Stream Template",
|
||||
"stream",
|
||||
"# this is a stream template"
|
||||
), (
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
(SELECT `id` FROM `user` WHERE `is_system` IS TRUE LIMIT 1),
|
||||
"Default Upstream Template",
|
||||
"upstream",
|
||||
"# ------------------------------------------------------------
|
||||
|
@ -4,7 +4,7 @@ CREATE TABLE "jwt_keys" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"public_key" TEXT NOT NULL,
|
||||
"private_key" TEXT NOT NULL
|
||||
);
|
||||
@ -13,12 +13,12 @@ CREATE TABLE "user" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"nickname" VARCHAR(50) NOT NULL,
|
||||
"email" VARCHAR(255) NOT NULL,
|
||||
"is_system" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_disabled" INTEGER NOT NULL DEFAULT 0
|
||||
"is_system" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"is_disabled" BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE "capability" (
|
||||
@ -36,7 +36,7 @@ CREATE TABLE "auth" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"type" VARCHAR(50) NOT NULL,
|
||||
"secret" VARCHAR(255) NOT NULL,
|
||||
@ -47,7 +47,7 @@ CREATE TABLE "setting" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"description" VARCHAR(255) NOT NULL DEFAULT '',
|
||||
"value" TEXT NOT NULL,
|
||||
@ -58,7 +58,7 @@ CREATE TABLE "audit_log" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"object_type" VARCHAR(50) NOT NULL,
|
||||
"object_id" INTEGER NOT NULL,
|
||||
@ -70,20 +70,20 @@ CREATE TABLE "certificate_authority" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"acmesh_server" VARCHAR(255) NOT NULL DEFAULT '',
|
||||
"ca_bundle" VARCHAR(255) NOT NULL DEFAULT '',
|
||||
"is_wildcard_supported" INTEGER NOT NULL DEFAULT 0, -- specific to each CA, acme v1 doesn't usually have wildcards
|
||||
"is_wildcard_supported" BOOLEAN NOT NULL DEFAULT FALSE, -- specific to each CA, acme v1 doesn't usually have wildcards
|
||||
"max_domains" INTEGER NOT NULL DEFAULT 5, -- per request
|
||||
"is_readonly" INTEGER NOT NULL DEFAULT 0
|
||||
"is_readonly" BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE "dns_provider" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"acmesh_name" VARCHAR(50) NOT NULL,
|
||||
@ -95,7 +95,7 @@ CREATE TABLE "certificate" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"type" VARCHAR(50) NOT NULL, -- custom,dns,http
|
||||
"certificate_authority_id" INTEGER REFERENCES "certificate_authority"("id"), -- 0 for a custom cert
|
||||
@ -106,28 +106,28 @@ CREATE TABLE "certificate" (
|
||||
"status" VARCHAR(50) NOT NULL, -- ready,requesting,failed,provided
|
||||
"error_message" TEXT NOT NULL DEFAULT '',
|
||||
"meta" TEXT NOT NULL,
|
||||
"is_ecc" INTEGER NOT NULL DEFAULT 0
|
||||
"is_ecc" BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE "stream" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"listen_interface" VARCHAR(50) NOT NULL,
|
||||
"incoming_port" INTEGER NOT NULL,
|
||||
"tcp_forwarding" INTEGER NOT NULL DEFAULT 0,
|
||||
"udp_forwarding" INTEGER NOT NULL DEFAULT 0,
|
||||
"advanced_config" TEXT NOT NULL,
|
||||
"is_disabled" INTEGER NOT NULL DEFAULT 0
|
||||
"is_disabled" BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE "nginx_template" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"type" VARCHAR(50) NOT NULL,
|
||||
@ -138,12 +138,12 @@ CREATE TABLE "upstream" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"nginx_template_id" INTEGER NOT NULL REFERENCES "nginx_template"("id"),
|
||||
"ip_hash" INTEGER NOT NULL DEFAULT 0,
|
||||
"ntlm" INTEGER NOT NULL DEFAULT 0,
|
||||
"ip_hash" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"ntlm" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"keepalive" INTEGER NOT NULL DEFAULT 0,
|
||||
"keepalive_requests" INTEGER NOT NULL DEFAULT 0,
|
||||
"keepalive_time" VARCHAR(50) NOT NULL DEFAULT '',
|
||||
@ -157,21 +157,21 @@ CREATE TABLE "upstream_server" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"upstream_id" INTEGER NOT NULL REFERENCES "upstream"("id"),
|
||||
"server" VARCHAR(50) NOT NULL,
|
||||
"weight" INTEGER NOT NULL DEFAULT 0,
|
||||
"max_conns" INTEGER NOT NULL DEFAULT 0,
|
||||
"max_fails" INTEGER NOT NULL DEFAULT 0,
|
||||
"fail_timeout" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_backup" INTEGER NOT NULL DEFAULT 0
|
||||
"is_backup" BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE "access_list" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"meta" TEXT NOT NULL
|
||||
@ -181,7 +181,7 @@ CREATE TABLE "host" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"created_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"updated_at" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism
|
||||
"user_id" INTEGER NOT NULL REFERENCES "user"("id"),
|
||||
"type" TEXT NOT NULL,
|
||||
"nginx_template_id" INTEGER NOT NULL REFERENCES "nginx_template"("id"),
|
||||
@ -193,18 +193,18 @@ CREATE TABLE "host" (
|
||||
"proxy_port" INTEGER NOT NULL DEFAULT 0,
|
||||
"certificate_id" INTEGER NOT NULL DEFAULT 0 REFERENCES "certificate"("id"),
|
||||
"access_list_id" INTEGER NOT NULL DEFAULT 0 REFERENCES "access_list"("id"),
|
||||
"ssl_forced" INTEGER NOT NULL DEFAULT 0,
|
||||
"caching_enabled" INTEGER NOT NULL DEFAULT 0,
|
||||
"block_exploits" INTEGER NOT NULL DEFAULT 0,
|
||||
"allow_websocket_upgrade" INTEGER NOT NULL DEFAULT 0,
|
||||
"http2_support" INTEGER NOT NULL DEFAULT 0,
|
||||
"hsts_enabled" INTEGER NOT NULL DEFAULT 0,
|
||||
"hsts_subdomains" INTEGER NOT NULL DEFAULT 0,
|
||||
"ssl_forced" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"caching_enabled" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"block_exploits" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"allow_websocket_upgrade" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"http2_support" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"hsts_enabled" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"hsts_subdomains" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"paths" TEXT NOT NULL DEFAULT '',
|
||||
"advanced_config" TEXT NOT NULL DEFAULT '',
|
||||
"status" TEXT NOT NULL DEFAULT '',
|
||||
"error_message" TEXT NOT NULL DEFAULT '',
|
||||
"is_disabled" INTEGER NOT NULL DEFAULT 0
|
||||
"is_disabled" BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
-- migrate:down
|
||||
|
@ -23,29 +23,23 @@ INSERT INTO "capability" (
|
||||
('streams.manage'),
|
||||
('users.manage');
|
||||
|
||||
-- Default error reporting setting
|
||||
INSERT INTO "setting" (
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"name",
|
||||
"description",
|
||||
"value"
|
||||
) VALUES (
|
||||
) VALUES
|
||||
-- Default error reporting setting
|
||||
(
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'error-reporting',
|
||||
'If enabled, any application errors are reported to Sentry. Sensitive information is not sent.',
|
||||
'true' -- remember this is json
|
||||
);
|
||||
|
||||
),
|
||||
-- Default site
|
||||
INSERT INTO "setting" (
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"name",
|
||||
"description",
|
||||
"value"
|
||||
) VALUES (
|
||||
(
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'default-site',
|
||||
@ -68,49 +62,49 @@ INSERT INTO "certificate_authority" (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'ZeroSSL',
|
||||
'zerossl',
|
||||
1,
|
||||
TRUE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'Let''s Encrypt',
|
||||
'https://acme-v02.api.letsencrypt.org/directory',
|
||||
1,
|
||||
TRUE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'Buypass Go SSL',
|
||||
'https://api.buypass.com/acme/directory',
|
||||
0,
|
||||
FALSE,
|
||||
5,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'SSL.com',
|
||||
'ssl.com',
|
||||
0,
|
||||
FALSE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'Let''s Encrypt (Testing)',
|
||||
'https://acme-staging-v02.api.letsencrypt.org/directory',
|
||||
1,
|
||||
TRUE,
|
||||
10,
|
||||
1
|
||||
TRUE
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
'Buypass Go SSL (Testing)',
|
||||
'https://api.test4.buypass.no/acme/directory',
|
||||
0,
|
||||
FALSE,
|
||||
5,
|
||||
1
|
||||
TRUE
|
||||
);
|
||||
|
||||
-- System User
|
||||
@ -127,7 +121,7 @@ INSERT INTO "user" (
|
||||
'System',
|
||||
'System',
|
||||
'system@localhost',
|
||||
1
|
||||
TRUE
|
||||
);
|
||||
|
||||
-- Host Templates
|
||||
@ -141,7 +135,7 @@ INSERT INTO "nginx_template" (
|
||||
) VALUES (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
(SELECT "id" FROM "user" WHERE "is_system" = 1 LIMIT 1),
|
||||
(SELECT "id" FROM "user" WHERE "is_system" IS TRUE LIMIT 1),
|
||||
'Default Proxy Template',
|
||||
'proxy',
|
||||
'# ------------------------------------------------------------
|
||||
@ -264,28 +258,28 @@ server {
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
(SELECT "id" FROM "user" WHERE "is_system" = 1 LIMIT 1),
|
||||
(SELECT "id" FROM "user" WHERE "is_system" IS TRUE LIMIT 1),
|
||||
'Default Redirect Template',
|
||||
'redirect',
|
||||
'# this is a redirect template'
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
(SELECT "id" FROM "user" WHERE "is_system" = 1 LIMIT 1),
|
||||
(SELECT "id" FROM "user" WHERE "is_system" IS TRUE LIMIT 1),
|
||||
'Default Dead Template',
|
||||
'dead',
|
||||
'# this is a dead template'
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
(SELECT "id" FROM "user" WHERE "is_system" = 1 LIMIT 1),
|
||||
(SELECT "id" FROM "user" WHERE "is_system" IS TRUE LIMIT 1),
|
||||
'Default Stream Template',
|
||||
'stream',
|
||||
'# this is a stream template'
|
||||
), (
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
|
||||
(SELECT "id" FROM "user" WHERE "is_system" = 1 LIMIT 1),
|
||||
(SELECT "id" FROM "user" WHERE "is_system" IS TRUE LIMIT 1),
|
||||
'Default Upstream Template',
|
||||
'upstream',
|
||||
'# ------------------------------------------------------------
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
gormlogger "gorm.io/gorm/logger"
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
@ -62,6 +63,7 @@ func connect() (*gorm.DB, error) {
|
||||
NoLowerCase: true,
|
||||
},
|
||||
PrepareStmt: false,
|
||||
Logger: gormlogger.Default.LogMode(gormlogger.Silent),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,9 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
// DeleteAll will do just that, and should only be used for testing purposes.
|
||||
func DeleteAll() error {
|
||||
db := database.GetDB()
|
||||
result := db.Exec("DELETE FROM user")
|
||||
// nolint errcheck
|
||||
db.Exec("DELETE FROM auth")
|
||||
result := db.Exec("DELETE FROM user WHERE is_system = ?", false)
|
||||
return result.Error
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user