From 82d61862f92fa6a50d8dd2f367189eb3ae9d5323 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 28 Jan 2011 17:56:57 +0100 Subject: [PATCH] Convert Horde_Perms to migrations. --- .../Horde/Perms/1_horde_perms_base_tables.php | 21 +++++++++++++++++++++ .../Perms/2_horde_perms_upgrade_autoincrement.php | 13 +++++++++++++ horde/scripts/sql/horde_perms.mysql.sql | 8 -------- horde/scripts/sql/horde_perms.oci8.sql | 15 --------------- horde/scripts/sql/horde_perms.pgsql.sql | 7 ------- horde/scripts/sql/horde_perms.sql | 7 ------- .../2010-05-24_horde_perms_autoincrement.mysql.sql | 1 - .../2010-05-24_horde_perms_autoincrement.oci8.sql | 7 ------- .../2010-05-24_horde_perms_autoincrement.pgsql.sql | 2 -- 9 files changed, 34 insertions(+), 47 deletions(-) create mode 100644 framework/Perms/migration/Horde/Perms/1_horde_perms_base_tables.php create mode 100644 framework/Perms/migration/Horde/Perms/2_horde_perms_upgrade_autoincrement.php delete mode 100644 horde/scripts/sql/horde_perms.mysql.sql delete mode 100644 horde/scripts/sql/horde_perms.oci8.sql delete mode 100644 horde/scripts/sql/horde_perms.pgsql.sql delete mode 100644 horde/scripts/sql/horde_perms.sql delete mode 100644 horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql delete mode 100644 horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.oci8.sql delete mode 100644 horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.pgsql.sql diff --git a/framework/Perms/migration/Horde/Perms/1_horde_perms_base_tables.php b/framework/Perms/migration/Horde/Perms/1_horde_perms_base_tables.php new file mode 100644 index 000000000..a2a8394cd --- /dev/null +++ b/framework/Perms/migration/Horde/Perms/1_horde_perms_base_tables.php @@ -0,0 +1,21 @@ +tables())) { + $t = $this->createTable('horde_perms', array('primaryKey' => array('perm_id'))); + $t->column('perm_id', 'integer', array('null' => false)); + $t->column('perm_name', 'string', array('limit' => 255, 'null' => false)); + $t->column('perm_parents', 'string', array('limit' => 255, 'null' => false)); + $t->column('perm_data', 'text'); + $t->end(); + $this->addIndex('horde_perms', array('perm_name'), array('unique' => true)); + } + } + + public function down() + { + $this->dropTable('horde_perms'); + } +} diff --git a/framework/Perms/migration/Horde/Perms/2_horde_perms_upgrade_autoincrement.php b/framework/Perms/migration/Horde/Perms/2_horde_perms_upgrade_autoincrement.php new file mode 100644 index 000000000..3516f5760 --- /dev/null +++ b/framework/Perms/migration/Horde/Perms/2_horde_perms_upgrade_autoincrement.php @@ -0,0 +1,13 @@ +changeColumn('horde_perms', 'perm_id', 'integer', array('null' => false, 'unsigned' => true, 'default' => null, 'autoincrement' => true)); + } + + public function down() + { + $this->changeColumn('horde_perms', 'perm_id', 'integer', array('null' => false)); + } +} \ No newline at end of file diff --git a/horde/scripts/sql/horde_perms.mysql.sql b/horde/scripts/sql/horde_perms.mysql.sql deleted file mode 100644 index eaaf62673..000000000 --- a/horde/scripts/sql/horde_perms.mysql.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE horde_perms ( - perm_id INT(11) NOT NULL AUTO_INCREMENT, - perm_name VARCHAR(255) NOT NULL, - perm_parents VARCHAR(255) NOT NULL, - perm_data TEXT, - PRIMARY KEY (perm_id), - UNIQUE KEY perm_name (perm_name) -); diff --git a/horde/scripts/sql/horde_perms.oci8.sql b/horde/scripts/sql/horde_perms.oci8.sql deleted file mode 100644 index 88b59c5e7..000000000 --- a/horde/scripts/sql/horde_perms.oci8.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE horde_perms ( - perm_id NUMBER(16) NOT NULL, - perm_name VARCHAR2(255) NOT NULL UNIQUE, - perm_parents VARCHAR2(255) NOT NULL, - 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 deleted file mode 100644 index bf2bee508..000000000 --- a/horde/scripts/sql/horde_perms.pgsql.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE horde_perms ( - perm_id SERIAL UNIQUE, - perm_name VARCHAR(255) NOT NULL UNIQUE, - perm_parents VARCHAR(255) NOT NULL, - perm_data TEXT, - PRIMARY KEY (perm_id) -); diff --git a/horde/scripts/sql/horde_perms.sql b/horde/scripts/sql/horde_perms.sql deleted file mode 100644 index f2fdeaa38..000000000 --- a/horde/scripts/sql/horde_perms.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE horde_perms ( - perm_id INTEGER NOT NULL AUTO_INCREMENT, - perm_name VARCHAR(255) NOT NULL, - perm_parents VARCHAR(255) NOT NULL, - perm_data TEXT, - PRIMARY KEY (perm_id) -); diff --git a/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql b/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql deleted file mode 100644 index 2f584f28a..000000000 --- a/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.mysql.sql +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 8a27c96ba..000000000 --- a/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.oci8.sql +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 2a2dd49a7..000000000 --- a/horde/scripts/upgrades/2010-05-24_horde_perms_autoincrement.pgsql.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE SEQUENCE horde_perms_id_seq; -ALTER TABLE horde_perms ALTER COLUMN perm_id SET DEFAULT NEXTVAL('horde_perms_id_seq'); -- 2.11.0