Moved v3 code from NginxProxyManager/nginx-proxy-manager-3 to NginxProxyManager/nginx-proxy-manager
This commit is contained in:
209
backend/embed/migrations/20201013035318_initial_schema.sql
Normal file
209
backend/embed/migrations/20201013035318_initial_schema.sql
Normal file
@ -0,0 +1,209 @@
|
||||
-- migrate:up
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `user`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
name TEXT NOT NULL,
|
||||
nickname TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
is_system INTEGER NOT NULL DEFAULT 0,
|
||||
is_disabled INTEGER NOT NULL DEFAULT 0,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `capability`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
UNIQUE (name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `user_has_capability`
|
||||
(
|
||||
user_id INTEGER NOT NULL,
|
||||
capability_id INTEGER NOT NULL,
|
||||
UNIQUE (user_id, capability_id),
|
||||
FOREIGN KEY (capability_id) REFERENCES capability (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `auth`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
secret TEXT NOT NULL,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id),
|
||||
UNIQUE (user_id, type)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `setting`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL DEFAULT "",
|
||||
value TEXT NOT NULL,
|
||||
UNIQUE (name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `audit_log`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
object_type TEXT NOT NULL,
|
||||
object_id INTEGER NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
meta TEXT NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `certificate_authority`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
name TEXT NOT NULL,
|
||||
acmesh_server TEXT NOT NULL DEFAULT "",
|
||||
ca_bundle TEXT NOT NULL DEFAULT "",
|
||||
is_wildcard_supported INTEGER NOT NULL DEFAULT 0, -- 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_deleted INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dns_provider`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
acmesh_name TEXT NOT NULL,
|
||||
dns_sleep INTEGER NOT NULL DEFAULT 0,
|
||||
meta TEXT NOT NULL,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `certificate`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
type TEXT NOT NULL, -- custom,dns,http
|
||||
user_id INTEGER NOT NULL,
|
||||
certificate_authority_id INTEGER, -- 0 for a custom cert
|
||||
dns_provider_id INTEGER, -- 0, for a http or custom cert
|
||||
name TEXT NOT NULL,
|
||||
domain_names TEXT NOT NULL,
|
||||
expires_on INTEGER DEFAULT 0,
|
||||
status TEXT NOT NULL, -- ready,requesting,failed,provided
|
||||
error_message text NOT NULL DEFAULT "",
|
||||
meta TEXT NOT NULL,
|
||||
is_ecc INTEGER NOT NULL DEFAULT 0,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
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)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `stream`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
listen_interface TEXT NOT NULL,
|
||||
incoming_port INTEGER NOT NULL,
|
||||
upstream_options TEXT 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_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `upstream`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
hosts TEXT NOT NULL,
|
||||
balance_method TEXT NOT NULL,
|
||||
max_fails INTEGER NOT NULL DEFAULT 1,
|
||||
fail_timeout INTEGER NOT NULL DEFAULT 10,
|
||||
advanced_config TEXT NOT NULL,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `access_list`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
meta TEXT NOT NULL,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `host_template`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
host_type TEXT NOT NULL,
|
||||
template TEXT NOT NULL,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `host`
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
modified_on INTEGER NOT NULL DEFAULT 0,
|
||||
user_id INTEGER NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
host_template_id INTEGER NOT NULL,
|
||||
listen_interface TEXT NOT NULL,
|
||||
domain_names TEXT NOT NULL,
|
||||
upstream_id INTEGER NOT NULL,
|
||||
certificate_id INTEGER,
|
||||
access_list_id INTEGER,
|
||||
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,
|
||||
paths TEXT NOT NULL,
|
||||
upstream_options TEXT NOT NULL DEFAULT "",
|
||||
advanced_config TEXT NOT NULL DEFAULT "",
|
||||
is_disabled INTEGER NOT NULL DEFAULT 0,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id),
|
||||
FOREIGN KEY (host_template_id) REFERENCES host_template (id),
|
||||
FOREIGN KEY (upstream_id) REFERENCES upstream (id),
|
||||
FOREIGN KEY (certificate_id) REFERENCES certificate (id),
|
||||
FOREIGN KEY (access_list_id) REFERENCES access_list (id)
|
||||
);
|
||||
|
||||
-- migrate:down
|
||||
|
||||
-- Not allowed to go down from initial
|
171
backend/embed/migrations/20201013035839_initial_data.sql
Normal file
171
backend/embed/migrations/20201013035839_initial_data.sql
Normal file
@ -0,0 +1,171 @@
|
||||
-- migrate:up
|
||||
|
||||
-- User permissions
|
||||
INSERT INTO `capability` (
|
||||
name
|
||||
) VALUES
|
||||
("full-admin"),
|
||||
("access-lists.view"),
|
||||
("access-lists.manage"),
|
||||
("audit-log.view"),
|
||||
("certificates.view"),
|
||||
("certificates.manage"),
|
||||
("certificate-authorities.view"),
|
||||
("certificate-authorities.manage"),
|
||||
("dns-providers.view"),
|
||||
("dns-providers.manage"),
|
||||
("hosts.view"),
|
||||
("hosts.manage"),
|
||||
("host-templates.view"),
|
||||
("host-templates.manage"),
|
||||
("settings.manage"),
|
||||
("streams.view"),
|
||||
("streams.manage"),
|
||||
("users.manage");
|
||||
|
||||
-- Default error reporting setting
|
||||
INSERT INTO `setting` (
|
||||
created_on,
|
||||
modified_on,
|
||||
name,
|
||||
description,
|
||||
value
|
||||
) VALUES (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"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_on,
|
||||
modified_on,
|
||||
name,
|
||||
description,
|
||||
value
|
||||
) VALUES (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"default-site",
|
||||
"What to show users who hit your Nginx server by default",
|
||||
'"welcome"' -- remember this is json
|
||||
);
|
||||
|
||||
-- Default Certificate Authorities
|
||||
|
||||
INSERT INTO `certificate_authority` (
|
||||
created_on,
|
||||
modified_on,
|
||||
name,
|
||||
acmesh_server,
|
||||
is_wildcard_supported,
|
||||
max_domains,
|
||||
is_readonly
|
||||
) VALUES (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"ZeroSSL",
|
||||
"zerossl",
|
||||
1,
|
||||
10,
|
||||
1
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"Let's Encrypt",
|
||||
"https://acme-v02.api.letsencrypt.org/directory",
|
||||
1,
|
||||
10,
|
||||
1
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"Buypass Go SSL",
|
||||
"https://api.buypass.com/acme/directory",
|
||||
0,
|
||||
5,
|
||||
1
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"Let's Encrypt (Testing)",
|
||||
"https://acme-staging-v02.api.letsencrypt.org/directory",
|
||||
1,
|
||||
10,
|
||||
1
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"Buypass Go SSL (Testing)",
|
||||
"https://api.test4.buypass.no/acme/directory",
|
||||
0,
|
||||
5,
|
||||
1
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"SSL.com",
|
||||
"ssl.com",
|
||||
0,
|
||||
10,
|
||||
1
|
||||
);
|
||||
|
||||
-- System User
|
||||
INSERT INTO `user` (
|
||||
created_on,
|
||||
modified_on,
|
||||
name,
|
||||
nickname,
|
||||
email,
|
||||
is_system
|
||||
) VALUES (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
"System",
|
||||
"System",
|
||||
"system@localhost",
|
||||
1
|
||||
);
|
||||
|
||||
-- Host Templates
|
||||
INSERT INTO `host_template` (
|
||||
created_on,
|
||||
modified_on,
|
||||
user_id,
|
||||
name,
|
||||
host_type,
|
||||
template
|
||||
) VALUES (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
"Default Proxy Template",
|
||||
"proxy",
|
||||
"# this is a proxy template"
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
"Default Redirect Template",
|
||||
"redirect",
|
||||
"# this is a redirect template"
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
"Default Dead Template",
|
||||
"dead",
|
||||
"# this is a dead template"
|
||||
), (
|
||||
strftime('%s', 'now'),
|
||||
strftime('%s', 'now'),
|
||||
(SELECT id FROM user WHERE is_system = 1 LIMIT 1),
|
||||
"Default Stream Template",
|
||||
"stream",
|
||||
"# this is a stream template"
|
||||
);
|
||||
|
||||
-- migrate:down
|
Reference in New Issue
Block a user