X-Git-Url: http://git.hcoop.net/hcoop/zz_old/portal.git/blobdiff_plain/f9d08b8c04c4174dac4f9c9e4750d39c3e6c5423..5146e43500ab781d22aefcb93f643a142ee65ff1:/tables.sql?ds=sidebyside

diff --git a/tables.sql b/tables.sql
index 9335981..ea72c45 100644
--- a/tables.sql
+++ b/tables.sql
@@ -1,3 +1,22 @@
+CREATE TABLE MemberApp(
+	id INTEGER PRIMARY KEY,
+	name TEXT NOT NULL,
+	rname TEXT NOT NULL,
+	gname TEXT,
+	email TEXT NOT NULL,
+	forward BOOLEAN NOT NULL,
+	uses TEXT NOT NULL,
+	other TEXT NOT NULL,
+	passwd TEXT NOT NULL,
+	status INTEGER NOT NULL,
+	applied TIMESTAMP NOT NULL,
+	ipaddr TEXT,
+	confirmed TIMESTAMP,
+	decided TIMESTAMP,
+	msg TEXT NOT NULL);
+
+CREATE SEQUENCE MemberAppSeq START 1;
+
 CREATE TABLE Balance(
 	id INTEGER PRIMARY KEY,
 	name TEXT NOT NULL,
@@ -15,7 +34,9 @@ CREATE TABLE WebUser(
 	rname TEXT NOT NULL,
 	bal INTEGER NOT NULL,
 	joined TIMESTAMP NOT NULL,
-	FOREIGN KEY (bal) REFERENCES Balance(id) ON DELETE CASCADE);
+	app INTEGER NOT NULL,
+	FOREIGN KEY (bal) REFERENCES Balance(id) ON DELETE CASCADE,
+	FOREIGN KEY (app) REFERENCES MemberApp(id) ON DELETE CASCADE);
 
 CREATE SEQUENCE WebUserSeq START 1;
 
@@ -219,23 +240,6 @@ CREATE TABLE DirectoryPref(
 	usr INTEGER PRIMARY KEY,
 	FOREIGN KEY (usr) REFERENCES WebUser(id) ON DELETE CASCADE);
 
-CREATE TABLE MemberApp(
-	id INTEGER PRIMARY KEY,
-	name TEXT NOT NULL,
-	rname TEXT NOT NULL,
-	email TEXT NOT NULL,
-	forward BOOLEAN NOT NULL,
-	uses TEXT NOT NULL,
-	other TEXT NOT NULL,
-	passwd TEXT NOT NULL,
-	status INTEGER NOT NULL,
-	applied TIMESTAMP NOT NULL,
-	confirmed TIMESTAMP,
-	decided TIMESTAMP,
-	msg TEXT NOT NULL);
-
-CREATE SEQUENCE MemberAppSeq START 1;
-
 CREATE TABLE AppVote(
 	app INTEGER NOT NULL,
 	usr INTEGER NOT NULL,
