Add autoincrement/sequence fields for horde_perms.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 24 May 2010 18:26:02 +0000 (14:26 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 24 May 2010 18:27:15 +0000 (14:27 -0400)
This fixes constraint violations due to the move to Horde_Db. Really
not 100% sure about the syntax for the oracle trigger...

12 files changed:
horde/scripts/sql/create.mssql.sql
horde/scripts/sql/create.mysql.sql
horde/scripts/sql/create.oci8.sql
horde/scripts/sql/create.pgsql.sql
horde/scripts/sql/create.sql
horde/scripts/sql/horde_perms.mysql.sql
horde/scripts/sql/horde_perms.oci8.sql
horde/scripts/sql/horde_perms.pgsql.sql
horde/scripts/sql/horde_perms.sql
horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql.sql [new file with mode: 0644]
horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.oci8.sql [new file with mode: 0644]
horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.pgsql.sql [new file with mode: 0644]

index bc00f81..a8b2498 100644 (file)
@@ -52,7 +52,7 @@ CREATE INDEX user_uid_idx ON horde_groups_members (user_uid)
 GO
 
 CREATE TABLE horde_perms (
-    perm_id INT NOT NULL,
+    perm_id INT NOT NULL IDENTITY,
     perm_name VARCHAR(255) NOT NULL,
     perm_parents VARCHAR(255) NOT NULL,
     perm_data TEXT,
index 23037f4..ed4acf1 100644 (file)
@@ -82,7 +82,7 @@ CREATE INDEX group_uid_idx ON horde_groups_members (group_uid);
 CREATE INDEX user_uid_idx ON horde_groups_members (user_uid);
 
 CREATE TABLE IF NOT EXISTS horde_perms (
-    perm_id INT(11) NOT NULL,
+    perm_id INT(11) NOT NULL AUTO_INCREMENT,
     perm_name VARCHAR(255) NOT NULL,
     perm_parents VARCHAR(255) NOT NULL,
     perm_data TEXT,
index bd8c79b..3ac1509 100644 (file)
@@ -86,6 +86,13 @@ CREATE TABLE horde_perms (
     perm_data CLOB,
     PRIMARY KEY (perm_id)
 );
+CREATE SEQUENCE horde_perms_id_seq;
+CREATE TRIGGER horde_perms_id_trigger
+BEFORE INSERT ON horde_perms
+FOR EACH ROW
+BEGIN
+SELECT horde_perms_id_seq.nextval INTO :new.permid FROM dual;
+END;
 
 /**
  * This is the Horde preferences table, holding all of the user-specific
index 05da0c5..0ba52ee 100644 (file)
@@ -44,8 +44,9 @@ CREATE TABLE horde_groups_members (
 CREATE INDEX group_uid_idx ON horde_groups_members (group_uid);
 CREATE INDEX user_uid_idx ON horde_groups_members (user_uid);
 
+CREATE SEQUENCE horde_perms_id_seq;
 CREATE TABLE horde_perms (
-    perm_id INTEGER NOT NULL,
+    perm_id INTEGER NOT NULL DEFAULT NEXTVAL('horde_perms_id_seq'),
     perm_name VARCHAR(255) NOT NULL UNIQUE,
     perm_parents VARCHAR(255) NOT NULL,
     perm_data TEXT,
index 675fa53..e6eb5f1 100644 (file)
@@ -33,7 +33,7 @@ CREATE INDEX user_uid_idx ON horde_groups_members (user_uid);
 
 
 CREATE TABLE horde_perms (
-    perm_id INTEGER NOT NULL,
+    perm_id INTEGER NOT NULL AUTO_INCREMENT,
     perm_name VARCHAR(255) NOT NULL,
     perm_parents VARCHAR(255) NOT NULL,
     perm_data TEXT,
index 9d7b919..eaaf626 100644 (file)
@@ -1,5 +1,5 @@
 CREATE TABLE horde_perms (
-    perm_id INT(11) NOT NULL,
+    perm_id INT(11) NOT NULL AUTO_INCREMENT,
     perm_name VARCHAR(255) NOT NULL,
     perm_parents VARCHAR(255) NOT NULL,
     perm_data TEXT,
index 6a55580..88b59c5 100644 (file)
@@ -5,3 +5,11 @@ CREATE TABLE horde_perms (
     perm_data CLOB,
     PRIMARY KEY (perm_id)
 );
+
+CREATE SEQUENCE horde_perms_id_seq;
+CREATE TRIGGER horde_perms_id_trigger
+BEFORE INSERT ON horde_perms
+FOR EACH ROW
+BEGIN
+SELECT horde_perms_id_seq.nextval INTO :new.permid FROM dual;
+END;
\ No newline at end of file
index 436a3a9..bd83391 100644 (file)
@@ -1,5 +1,6 @@
+CREATE SEQUENCE horde_perms_id_seq;
 CREATE TABLE horde_perms (
-    perm_id INTEGER NOT NULL,
+    perm_id INTEGER NOT NULL DEFAULT NEXTVAL('horde_perms_id_seq'),
     perm_name VARCHAR(255) NOT NULL UNIQUE,
     perm_parents VARCHAR(255) NOT NULL,
     perm_data TEXT,
index 974450f..f2fdeaa 100644 (file)
@@ -1,5 +1,5 @@
 CREATE TABLE horde_perms (
-    perm_id INTEGER NOT NULL,
+    perm_id INTEGER NOT NULL AUTO_INCREMENT,
     perm_name VARCHAR(255) NOT NULL,
     perm_parents VARCHAR(255) NOT NULL,
     perm_data TEXT,
diff --git a/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql.sql b/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql.sql
new file mode 100644 (file)
index 0000000..2f584f2
--- /dev/null
@@ -0,0 +1 @@
+ALTER TABLE horde_perms CHANGE COLUMN perm_id perm_id INT(11) NOT NULL AUTO_INCREMENT;
\ No newline at end of file
diff --git a/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.oci8.sql b/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.oci8.sql
new file mode 100644 (file)
index 0000000..8a27c96
--- /dev/null
@@ -0,0 +1,7 @@
+CREATE SEQUENCE horde_perms_id_seq;
+CREATE TRIGGER horde_perms_id_trigger
+BEFORE INSERT ON horde_perms
+FOR EACH ROW
+BEGIN
+SELECT horde_perms_id_seq.nextval INTO :new.permid FROM dual;
+END;
diff --git a/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.pgsql.sql b/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.pgsql.sql
new file mode 100644 (file)
index 0000000..2a2dd49
--- /dev/null
@@ -0,0 +1,2 @@
+CREATE SEQUENCE horde_perms_id_seq;
+ALTER TABLE horde_perms ALTER COLUMN perm_id SET DEFAULT NEXTVAL('horde_perms_id_seq');