From: Michael J. Rubinsky Date: Mon, 24 May 2010 18:26:02 +0000 (-0400) Subject: Add autoincrement/sequence fields for horde_perms. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8d1045506d8c987d270982c7c9d7d1088d5d6d43;p=horde.git Add autoincrement/sequence fields for horde_perms. This fixes constraint violations due to the move to Horde_Db. Really not 100% sure about the syntax for the oracle trigger... --- diff --git a/horde/scripts/sql/create.mssql.sql b/horde/scripts/sql/create.mssql.sql index bc00f8164..a8b249836 100644 --- a/horde/scripts/sql/create.mssql.sql +++ b/horde/scripts/sql/create.mssql.sql @@ -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, diff --git a/horde/scripts/sql/create.mysql.sql b/horde/scripts/sql/create.mysql.sql index 23037f4b1..ed4acf143 100644 --- a/horde/scripts/sql/create.mysql.sql +++ b/horde/scripts/sql/create.mysql.sql @@ -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, diff --git a/horde/scripts/sql/create.oci8.sql b/horde/scripts/sql/create.oci8.sql index bd8c79bf7..3ac150943 100644 --- a/horde/scripts/sql/create.oci8.sql +++ b/horde/scripts/sql/create.oci8.sql @@ -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 diff --git a/horde/scripts/sql/create.pgsql.sql b/horde/scripts/sql/create.pgsql.sql index 05da0c5cf..0ba52ee36 100644 --- a/horde/scripts/sql/create.pgsql.sql +++ b/horde/scripts/sql/create.pgsql.sql @@ -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, diff --git a/horde/scripts/sql/create.sql b/horde/scripts/sql/create.sql index 675fa5336..e6eb5f19d 100644 --- a/horde/scripts/sql/create.sql +++ b/horde/scripts/sql/create.sql @@ -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, diff --git a/horde/scripts/sql/horde_perms.mysql.sql b/horde/scripts/sql/horde_perms.mysql.sql index 9d7b91975..eaaf62673 100644 --- a/horde/scripts/sql/horde_perms.mysql.sql +++ b/horde/scripts/sql/horde_perms.mysql.sql @@ -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, diff --git a/horde/scripts/sql/horde_perms.oci8.sql b/horde/scripts/sql/horde_perms.oci8.sql index 6a55580f1..88b59c5e7 100644 --- a/horde/scripts/sql/horde_perms.oci8.sql +++ b/horde/scripts/sql/horde_perms.oci8.sql @@ -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 diff --git a/horde/scripts/sql/horde_perms.pgsql.sql b/horde/scripts/sql/horde_perms.pgsql.sql index 436a3a9bf..bd8339157 100644 --- a/horde/scripts/sql/horde_perms.pgsql.sql +++ b/horde/scripts/sql/horde_perms.pgsql.sql @@ -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, diff --git a/horde/scripts/sql/horde_perms.sql b/horde/scripts/sql/horde_perms.sql index 974450f2e..f2fdeaa38 100644 --- a/horde/scripts/sql/horde_perms.sql +++ b/horde/scripts/sql/horde_perms.sql @@ -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 index 000000000..2f584f28a --- /dev/null +++ b/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql.sql @@ -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 index 000000000..8a27c96ba --- /dev/null +++ b/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.oci8.sql @@ -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 index 000000000..2a2dd49a7 --- /dev/null +++ b/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.pgsql.sql @@ -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');