mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-10-30 23:33:34 +00:00 
			
		
		
		
	Add ON DELETE CASCADE for testing query
This commit is contained in:
		| @@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS `user_has_capability` | ||||
| 	`user_id` INT NOT NULL, | ||||
| 	`capability_name` VARCHAR(50) NOT NULL, | ||||
| 	UNIQUE (`user_id`, `capability_name`), | ||||
| 	FOREIGN KEY (`capability_name`) REFERENCES `capability`(`name`) | ||||
| 	FOREIGN KEY (`capability_name`) REFERENCES `capability`(`name`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS `auth` | ||||
| @@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS `auth` | ||||
| 	`user_id` INT NOT NULL, | ||||
| 	`type` VARCHAR(50) NOT NULL, | ||||
| 	`secret` VARCHAR(255) NOT NULL, | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`), | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE, | ||||
| 	UNIQUE (`user_id`, `type`) | ||||
| ); | ||||
|  | ||||
| @@ -73,7 +73,7 @@ CREATE TABLE IF NOT EXISTS `audit_log` | ||||
| 	`object_id` INT NOT NULL, | ||||
| 	`action` VARCHAR(50) NOT NULL, | ||||
| 	`meta` TEXT NOT NULL, | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS `certificate_authority` | ||||
| @@ -101,7 +101,7 @@ CREATE TABLE IF NOT EXISTS `dns_provider` | ||||
| 	`acmesh_name` VARCHAR(50) NOT NULL, | ||||
| 	`dns_sleep` INT NOT NULL DEFAULT 0, | ||||
| 	`meta` TEXT NOT NULL, | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS certificate | ||||
| @@ -121,9 +121,9 @@ CREATE TABLE IF NOT EXISTS certificate | ||||
| 	`error_message` TEXT NOT NULL, | ||||
| 	`meta` TEXT NOT NULL, | ||||
| 	`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`) | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE, | ||||
| 	FOREIGN KEY (`certificate_authority_id`) REFERENCES `certificate_authority`(`id`) ON DELETE CASCADE, | ||||
| 	FOREIGN KEY (`dns_provider_id`) REFERENCES `dns_provider`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS `stream` | ||||
| @@ -139,7 +139,7 @@ CREATE TABLE IF NOT EXISTS `stream` | ||||
| 	`udp_forwarding` INT NOT NULL DEFAULT 0, | ||||
| 	`advanced_config` TEXT NOT NULL, | ||||
| 	`is_disabled` BOOLEAN NOT NULL DEFAULT FALSE, | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS `nginx_template` | ||||
| @@ -173,8 +173,8 @@ CREATE TABLE IF NOT EXISTS `upstream` | ||||
| 	`advanced_config` TEXT NOT NULL, | ||||
| 	`status` VARCHAR(50) NOT NULL DEFAULT '', | ||||
| 	`error_message` TEXT NOT NULL, | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`), | ||||
| 	FOREIGN KEY (`nginx_template_id`) REFERENCES `nginx_template`(`id`) | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE, | ||||
| 	FOREIGN KEY (`nginx_template_id`) REFERENCES `nginx_template`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS `upstream_server` | ||||
| @@ -190,7 +190,7 @@ CREATE TABLE IF NOT EXISTS `upstream_server` | ||||
| 	`max_fails` INT NOT NULL DEFAULT 0, | ||||
| 	`fail_timeout` INT NOT NULL DEFAULT 0, | ||||
| 	`is_backup` BOOLEAN NOT NULL DEFAULT FALSE, | ||||
| 	FOREIGN KEY (`upstream_id`) REFERENCES `upstream`(`id`) | ||||
| 	FOREIGN KEY (`upstream_id`) REFERENCES `upstream`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS `access_list` | ||||
| @@ -202,7 +202,7 @@ CREATE TABLE IF NOT EXISTS `access_list` | ||||
| 	`user_id` INT NOT NULL, | ||||
| 	`name` VARCHAR(50) NOT NULL, | ||||
| 	`meta` TEXT NOT NULL, | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS host | ||||
| @@ -234,11 +234,11 @@ CREATE TABLE IF NOT EXISTS host | ||||
| 	`status` VARCHAR(50) NOT NULL DEFAULT '', | ||||
| 	`error_message` TEXT NOT NULL, | ||||
| 	`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`), | ||||
| 	FOREIGN KEY (`certificate_id`) REFERENCES `certificate`(`id`), | ||||
| 	FOREIGN KEY (`access_list_id`) REFERENCES `access_list`(`id`) | ||||
| 	FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE, | ||||
| 	FOREIGN KEY (`nginx_template_id`) REFERENCES `nginx_template`(`id`) ON DELETE CASCADE, | ||||
| 	FOREIGN KEY (`upstream_id`) REFERENCES `upstream`(`id`) ON DELETE CASCADE, | ||||
| 	FOREIGN KEY (`certificate_id`) REFERENCES `certificate`(`id`) ON DELETE CASCADE, | ||||
| 	FOREIGN KEY (`access_list_id`) REFERENCES `access_list`(`id`) ON DELETE CASCADE | ||||
| ); | ||||
|  | ||||
| -- migrate:down | ||||
|   | ||||
| @@ -28,7 +28,7 @@ CREATE TABLE "capability" ( | ||||
|  | ||||
| CREATE TABLE "user_has_capability" ( | ||||
| 	"user_id" INTEGER NOT NULL, | ||||
| 	"capability_name" TEXT NOT NULL REFERENCES "capability"("name"), | ||||
| 	"capability_name" TEXT NOT NULL REFERENCES "capability"("name") ON DELETE CASCADE, | ||||
| 	UNIQUE ("user_id", "capability_name") | ||||
| ); | ||||
|  | ||||
| @@ -37,7 +37,7 @@ CREATE TABLE "auth" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"type" VARCHAR(50) NOT NULL, | ||||
| 	"secret" VARCHAR(255) NOT NULL, | ||||
| 	UNIQUE ("user_id", "type") | ||||
| @@ -59,7 +59,7 @@ CREATE TABLE "audit_log" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"object_type" VARCHAR(50) NOT NULL, | ||||
| 	"object_id" INTEGER NOT NULL, | ||||
| 	"action" VARCHAR(50) NOT NULL, | ||||
| @@ -84,7 +84,7 @@ CREATE TABLE "dns_provider" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"name" VARCHAR(50) NOT NULL, | ||||
| 	"acmesh_name" VARCHAR(50) NOT NULL, | ||||
| 	"dns_sleep" INTEGER NOT NULL DEFAULT 0, | ||||
| @@ -96,10 +96,10 @@ CREATE TABLE "certificate" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"type" VARCHAR(50) NOT NULL, -- custom,dns,http | ||||
| 	"certificate_authority_id" INTEGER REFERENCES "certificate_authority"("id"), -- 0 for a custom cert | ||||
| 	"dns_provider_id" INTEGER REFERENCES "dns_provider"("id"), -- 0, for a http or custom cert | ||||
| 	"certificate_authority_id" INTEGER REFERENCES "certificate_authority"("id") ON DELETE CASCADE, -- 0 for a custom cert | ||||
| 	"dns_provider_id" INTEGER REFERENCES "dns_provider"("id") ON DELETE CASCADE, -- 0, for a http or custom cert | ||||
| 	"name" VARCHAR(50) NOT NULL, | ||||
| 	"domain_names" TEXT NOT NULL, | ||||
| 	"expires_on" INTEGER DEFAULT 0, | ||||
| @@ -114,7 +114,7 @@ CREATE TABLE "stream" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"listen_interface" VARCHAR(50) NOT NULL, | ||||
| 	"incoming_port" INTEGER NOT NULL, | ||||
| 	"tcp_forwarding" INTEGER NOT NULL DEFAULT 0, | ||||
| @@ -128,7 +128,7 @@ CREATE TABLE "nginx_template" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"name" VARCHAR(50) NOT NULL, | ||||
| 	"type" VARCHAR(50) NOT NULL, | ||||
| 	"template" TEXT NOT NULL | ||||
| @@ -141,7 +141,7 @@ CREATE TABLE "upstream" ( | ||||
| 	"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"), | ||||
| 	"nginx_template_id" INTEGER NOT NULL REFERENCES "nginx_template"("id") ON DELETE CASCADE, | ||||
| 	"ip_hash" BOOLEAN NOT NULL DEFAULT FALSE, | ||||
| 	"ntlm" BOOLEAN NOT NULL DEFAULT FALSE, | ||||
| 	"keepalive" INTEGER NOT NULL DEFAULT 0, | ||||
| @@ -158,7 +158,7 @@ CREATE TABLE "upstream_server" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"upstream_id" INTEGER NOT NULL REFERENCES "upstream"("id"), | ||||
| 	"upstream_id" INTEGER NOT NULL REFERENCES "upstream"("id") ON DELETE CASCADE, | ||||
| 	"server" VARCHAR(50) NOT NULL, | ||||
| 	"weight" INTEGER NOT NULL DEFAULT 0, | ||||
| 	"max_conns" INTEGER NOT NULL DEFAULT 0, | ||||
| @@ -172,7 +172,7 @@ CREATE TABLE "access_list" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"name" VARCHAR(50) NOT NULL, | ||||
| 	"meta" TEXT NOT NULL | ||||
| ); | ||||
| @@ -182,17 +182,17 @@ CREATE TABLE "host" ( | ||||
| 	"created_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"updated_at" BIGINT NOT NULL DEFAULT 0, | ||||
| 	"is_deleted" INTEGER NOT NULL DEFAULT 0, -- int on purpose, gormism | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id"), | ||||
| 	"user_id" INTEGER NOT NULL REFERENCES "user"("id") ON DELETE CASCADE, | ||||
| 	"type" TEXT NOT NULL, | ||||
| 	"nginx_template_id" INTEGER NOT NULL REFERENCES "nginx_template"("id"), | ||||
| 	"nginx_template_id" INTEGER NOT NULL REFERENCES "nginx_template"("id") ON DELETE CASCADE, | ||||
| 	"listen_interface" TEXT NOT NULL DEFAULT '', | ||||
| 	"domain_names" TEXT NOT NULL, | ||||
| 	"upstream_id" INTEGER NOT NULL DEFAULT 0 REFERENCES "upstream"("id"), | ||||
| 	"upstream_id" INTEGER NOT NULL DEFAULT 0 REFERENCES "upstream"("id") ON DELETE CASCADE, | ||||
| 	"proxy_scheme" TEXT NOT NULL DEFAULT '', | ||||
| 	"proxy_host" TEXT NOT NULL DEFAULT '', | ||||
| 	"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"), | ||||
| 	"certificate_id" INTEGER NOT NULL DEFAULT 0 REFERENCES "certificate"("id") ON DELETE CASCADE, | ||||
| 	"access_list_id" INTEGER NOT NULL DEFAULT 0 REFERENCES "access_list"("id") ON DELETE CASCADE, | ||||
| 	"ssl_forced" BOOLEAN NOT NULL DEFAULT FALSE, | ||||
| 	"caching_enabled" BOOLEAN NOT NULL DEFAULT FALSE, | ||||
| 	"block_exploits" BOOLEAN NOT NULL DEFAULT FALSE, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user