Convert Horde_Prefs to migrations.
authorJan Schneider <jan@horde.org>
Fri, 28 Jan 2011 17:05:33 +0000 (18:05 +0100)
committerJan Schneider <jan@horde.org>
Fri, 28 Jan 2011 18:07:05 +0000 (19:07 +0100)
framework/Prefs/migration/Horde/Prefs/1_horde_prefs_base_tables.php [new file with mode: 0644]
horde/scripts/sql/horde_prefs.mssql.sql [deleted file]
horde/scripts/sql/horde_prefs.pgsql.sql [deleted file]
horde/scripts/sql/horde_prefs.sql [deleted file]
horde/scripts/upgrades/2005-09-22_horde_prefs_varchar2.oci8.sql [deleted file]
horde/scripts/upgrades/2006-06-29_horde_prefs_indexes.sql [deleted file]

diff --git a/framework/Prefs/migration/Horde/Prefs/1_horde_prefs_base_tables.php b/framework/Prefs/migration/Horde/Prefs/1_horde_prefs_base_tables.php
new file mode 100644 (file)
index 0000000..2c85f3c
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+class HordePrefsBaseTables extends Horde_Db_Migration_Base
+{
+    public function up()
+    {
+        if (!in_array('horde_prefs', $this->tables())) {
+            $t = $this->createTable('horde_prefs', array('primaryKey' => array('pref_uid', 'pref_scope', 'pref_name')));
+            $t->column('pref_uid', 'string', array('limit' => 255, 'null' => false));
+            $t->column('pref_scope', 'string', array('limit' => 16, 'null' => false, 'default' => ''));
+            $t->column('pref_name', 'string', array('limit' => 32, 'null' => false));
+            $t->column('pref_value', 'text');
+            $t->end();
+            $this->addIndex('horde_prefs', array('pref_uid'));
+            $this->addIndex('horde_prefs', array('pref_scope'));
+        }
+    }
+
+    public function down()
+    {
+        $this->dropTable('horde_prefs');
+    }
+}
diff --git a/horde/scripts/sql/horde_prefs.mssql.sql b/horde/scripts/sql/horde_prefs.mssql.sql
deleted file mode 100644 (file)
index d09c025..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-CREATE TABLE horde_prefs (
-    pref_uid        VARCHAR(255) NOT NULL,
-    pref_scope      VARCHAR(16) DEFAULT '' NOT NULL,
-    pref_name       VARCHAR(32) NOT NULL,
-    pref_value      VARCHAR(MAX),
---
-    PRIMARY KEY (pref_uid, pref_scope, pref_name)
-);
-
-CREATE INDEX pref_uid_idx ON horde_prefs (pref_uid);
-CREATE INDEX pref_scope_idx ON horde_prefs (pref_scope);
diff --git a/horde/scripts/sql/horde_prefs.pgsql.sql b/horde/scripts/sql/horde_prefs.pgsql.sql
deleted file mode 100644 (file)
index 2103f56..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-CREATE TABLE horde_prefs (
-    pref_uid        VARCHAR(255) NOT NULL,
-    pref_scope      VARCHAR(16) DEFAULT '' NOT NULL,
-    pref_name       VARCHAR(32) NOT NULL,
-    pref_value      BYTEA,
---
-    PRIMARY KEY (pref_uid, pref_scope, pref_name)
-);
-
-CREATE INDEX pref_uid_idx ON horde_prefs (pref_uid);
-CREATE INDEX pref_scope_idx ON horde_prefs (pref_scope);
diff --git a/horde/scripts/sql/horde_prefs.sql b/horde/scripts/sql/horde_prefs.sql
deleted file mode 100644 (file)
index 3fef854..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-CREATE TABLE horde_prefs (
-    pref_uid        VARCHAR(255) NOT NULL,
-    pref_scope      VARCHAR(16) DEFAULT '' NOT NULL,
-    pref_name       VARCHAR(32) NOT NULL,
-    pref_value      TEXT,
---
-    PRIMARY KEY (pref_uid, pref_scope, pref_name)
-);
-
-CREATE INDEX pref_uid_idx ON horde_prefs (pref_uid);
-CREATE INDEX pref_scope_idx ON horde_prefs (pref_scope);
diff --git a/horde/scripts/upgrades/2005-09-22_horde_prefs_varchar2.oci8.sql b/horde/scripts/upgrades/2005-09-22_horde_prefs_varchar2.oci8.sql
deleted file mode 100644 (file)
index d67ac74..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
--- Use this script to convert CHAR columns in horde_prefs to VARCHAR2 and trim
--- the space padding.  This is only necessary if horde_prefs was created using
--- scripts/sql/create.oci8.sql
-ALTER TABLE horde_prefs MODIFY pref_uid VARCHAR2(255);
-ALTER TABLE horde_prefs MODIFY pref_scope VARCHAR2(16);
-ALTER TABLE horde_prefs MODIFY pref_name VARCHAR2(32);
-UPDATE horde_prefs SET pref_uid = RTRIM(pref_uid);
-UPDATE horde_prefs SET pref_scope = RTRIM(pref_scope);
-UPDATE horde_prefs SET pref_name = RTRIM(pref_name);
diff --git a/horde/scripts/upgrades/2006-06-29_horde_prefs_indexes.sql b/horde/scripts/upgrades/2006-06-29_horde_prefs_indexes.sql
deleted file mode 100644 (file)
index 17f9ac2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
--- This script adds additional indexes to the horde_prefs table that should
--- improve loading of preferences from the preference table.
-
-CREATE INDEX pref_uid_idx ON horde_prefs (pref_uid);
-CREATE INDEX pref_scope_idx ON horde_prefs (pref_scope);
-