From b127d65e62715cf191d4e0f479da54ae310ed863 Mon Sep 17 00:00:00 2001
From: Purodha Blissenbach <purodha.blissenbach@hostsharing.net>
Date: Fri, 21 Sep 2012 13:50:45 +0200
Subject: [PATCH] Database migration to version 2.2 begun.

---
 hsarback/database/schema.sql |   69 +++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/hsarback/database/schema.sql b/hsarback/database/schema.sql
index cb2a11a..80bd3ac 100644
--- a/hsarback/database/schema.sql
+++ b/hsarback/database/schema.sql
@@ -17,17 +17,6 @@
 
 
 --
--- Name: bank_account_bank_account_i_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE bank_account_bank_account_i_seq
-    INCREMENT BY 1
-    NO MAXVALUE
-    NO MINVALUE
-    CACHE 1;
-
-
---
 -- Name: bank_account_bank_account_id_seq; Type: SEQUENCE; Schema: public; Owner: -
 --
 
@@ -133,7 +122,7 @@
     uid_vat character varying(20),
     CONSTRAINT ckc_member_id_business CHECK (((member_id >= 10000) AND (member_id <= 99999))),
     CONSTRAINT ckc_shares_signed_business CHECK ((shares_signed >= 0)),
-    CONSTRAINT ckt_business_partner CHECK ((((((member_since IS NULL) AND (member_until IS NULL)) OR ((member_since IS NOT NULL) AND (member_until IS NULL))) OR (((member_since IS NOT NULL) AND (member_until IS NOT NULL)) AND (member_since < member_until))) AND ((((member_code)::text ~~ 'hsh00-%'::text) AND (member_since IS NOT NULL)) OR (((member_code)::text !~~ 'hsh00-%'::text) AND (member_since IS NULL)))))
+    CONSTRAINT ckt_business_partner CHECK ( ( ((member_since IS NULL) AND (member_until IS NULL)) OR ((member_since IS NOT NULL) AND (member_until IS NULL)) OR ((member_since IS NOT NULL) AND (member_until IS NOT NULL) AND (member_since < member_until)) ) AND ((member_code)::text ~~ 'hsh00-%'::text))
 );
 
 
@@ -269,17 +258,10 @@
 
 CREATE TABLE domain (
     domain_name character varying(256) NOT NULL,
-    domain_status character varying(12) NOT NULL,
-    domain_status_changed date NOT NULL,
-    domain_filed date,
     domain_since date,
-    domain_until date,
     domain_dns_master character varying(64),
     domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL,
-    domain_owner integer NOT NULL,
-    domain_reminder date,
-    domain_free boolean DEFAULT false NOT NULL,
-    domain_template character varying(32)
+    domain_owner integer NOT NULL
 );
 
 
@@ -375,17 +357,6 @@
     INCREMENT BY 1
     NO MAXVALUE
     NO MINVALUE
-    CACHE 1;
-
-
---
--- Name: member_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE member_id_seq
-    INCREMENT BY 1
-    MAXVALUE 99999
-    MINVALUE 10200
     CACHE 1;
 
 
@@ -929,11 +900,39 @@
 ALTER TABLE ONLY queue_task
     ADD CONSTRAINT queue_task_user_id_fkey FOREIGN KEY (user_id) REFERENCES unixuser(unixuser_id) ON DELETE SET NULL;
 
-
 --
--- Name: queue_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+-- domain options
 --
 
-ALTER TABLE ONLY queue
-    ADD CONSTRAINT queue_user_id_fkey FOREIGN KEY (user_id) REFERENCES unixuser(unixuser_id) DEFERRABLE;
+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;
 

--
Gitblit v1.9.1