From e5fe2a57f7c33935774b8a6cac206c4a2818132b Mon Sep 17 00:00:00 2001
From: Purodha Blissenbach <purodha.blissenbach@hostsharing.net>
Date: Wed, 31 Oct 2012 11:37:07 +0100
Subject: [PATCH] Added domainoption: php (data base changes only)

---
 hsarback/database/database_update.sql |   87 +++++++++----------------------------------
 1 files changed, 19 insertions(+), 68 deletions(-)

diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql
index dd855d7..04b41fb 100644
--- a/hsarback/database/database_update.sql
+++ b/hsarback/database/database_update.sql
@@ -1,80 +1,31 @@
--- Migrate database from version 2.1 to version 2.2
+-- Migrate database from version 2.2 to version 2.3
 --
--- domain options
---
-CREATE SEQUENCE domain_option_id_seq
-    INCREMENT BY 1
-    NO MAXVALUE
-    NO MINVALUE
-    CACHE 1;
-
-CREATE TABLE domain_option (
-    domain_option_id integer DEFAULT nextval(('"domain_option_id_seq"'::text)::regclass) NOT NULL,
-    domain_option_name character varying(50) NOT NULL
-);
-
-ALTER TABLE ONLY domain_option
-    ADD CONSTRAINT pk_domain_option PRIMARY KEY (domain_option_id);
-
-CREATE UNIQUE INDEX domain_option_name_idx ON domain_option USING btree ( domain_option_name );
-    
-CREATE TABLE domain__domain_option (
-	domain_option_id integer NOT NULL,
-	domain_id integer NOT NULL
-); 
-
-ALTER TABLE ONLY domain__domain_option
-    ADD CONSTRAINT pk_domain__domain_option PRIMARY KEY (domain_option_id, domain_id);
-
-ALTER TABLE ONLY domain__domain_option
-    ADD CONSTRAINT domain_option_id_fkey FOREIGN KEY (domain_option_id) 
-    	REFERENCES domain_option(domain_option_id) DEFERRABLE;
-
-ALTER TABLE ONLY domain__domain_option
-    ADD CONSTRAINT domain_id_fkey FOREIGN KEY (domain_id) 
-    	REFERENCES domain(domain_id) DEFERRABLE;
 
 --
 -- table: domain_option
 --
-INSERT INTO domain_option (domain_option_name) 
-	VALUES ('backupmxforexternalmx');
-INSERT INTO domain_option (domain_option_name) 
-	VALUES ('greylisting');
 INSERT INTO domain_option (domain_option_name)
-	VALUES ('htdocsfallback');
-INSERT INTO domain_option (domain_option_name) 
-	VALUES ('includes');
-INSERT INTO domain_option (domain_option_name) 
-	VALUES ('indexes');
-INSERT INTO domain_option (domain_option_name)
-	VALUES ('multiviews');
+	VALUES ('php');
 --
 -- new domain options settings
 --
--- existing default = ON
---
-INSERT INTO domain__domain_option 	SELECT domain_option_id, domain_id
-	FROM domain, domain_option
-	WHERE domain_option.domain_option_name = 'greylisting' ;
+-- existing default = On for DW-packet, Off otherwise.
+--	
 INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
-	FROM domain, domain_option
-	WHERE domain_option.domain_option_name = 'htdocsfallback' ;
-INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
-	FROM domain, domain_option
-	WHERE domain_option.domain_option_name = 'includes' ;
-INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
-	FROM domain, domain_option
-	WHERE domain_option.domain_option_name = 'indexes' ;
-INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
-	FROM domain, domain_option
-	WHERE domain_option.domain_option_name = 'multiviews' ;
+	FROM domain
+			JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id ) 
+			JOIN packet on ( unixuser.packet_id = packet.packet_id ) 
+			JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id )
+		, domain_option
+	WHERE basepacket.basepacket_code = 'DW/B'  
+		AND domain_option.domain_option_name = 'php' ;
+DELETE FROM domain__domain_option USING domain_option, domain
+		JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id ) 
+		JOIN packet on ( unixuser.packet_id = packet.packet_id ) 
+		JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id )
+	WHERE basepacket.basepacket_code != 'DW/B'
+		AND domain__domain_option.domain_option_id = domain_option.domain_option_id
+		AND domain_option.domain_option_name = 'php' ;
 --
--- existing default = OFF
---
-DELETE FROM domain__domain_option USING domain_option
-	WHERE domain__domain_option.domain_option_id = domain_option.domain_option_id
-		AND domain_option.domain_option_name = 'backupmxforexternalmx' ;
---
--- End of migratino to version 2.2
+-- End of migration to version 2.3
 --

--
Gitblit v1.9.0-SNAPSHOT