Convert Horde_VFS to migrations.
authorJan Schneider <jan@horde.org>
Fri, 28 Jan 2011 16:49:20 +0000 (17:49 +0100)
committerJan Schneider <jan@horde.org>
Fri, 28 Jan 2011 18:07:05 +0000 (19:07 +0100)
framework/VFS/migration/Horde/VFS/1_horde_vfs_base_tables.php [new file with mode: 0644]
framework/VFS/migration/Horde/VFS/2_horde_vfs_upgrade_autoincrement.php [new file with mode: 0644]
horde/scripts/sql/horde_muvfs.mssql.sql [deleted file]
horde/scripts/sql/horde_muvfs.sql [deleted file]
horde/scripts/sql/horde_vfs.mssql.sql [deleted file]
horde/scripts/sql/horde_vfs.oci8.sql [deleted file]
horde/scripts/sql/horde_vfs.pgsql.sql [deleted file]
horde/scripts/sql/horde_vfs.sql [deleted file]

diff --git a/framework/VFS/migration/Horde/VFS/1_horde_vfs_base_tables.php b/framework/VFS/migration/Horde/VFS/1_horde_vfs_base_tables.php
new file mode 100644 (file)
index 0000000..928aeb0
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+class HordeVfsBaseTables extends Horde_Db_Migration_Base
+{
+    public function up()
+    {
+        if (!in_array('horde_vfs', $this->tables())) {
+            $t = $this->createTable('horde_vfs', array('primaryKey' => array('vfs_id')));
+            $t->column('vfs_id', 'int', array('null' => false, 'unsigned' => true));
+            $t->column('vfs_type', 'smallint', array('null' => false, 'unsigned' => true));
+            $t->column('vfs_path', 'string', array('limit' => 255, 'null' => false));
+            $t->column('vfs_name', 'string', array('limit' => 255, 'null' => false));
+            $t->column('vfs_modified', 'bigint', array('null' => false));
+            $t->column('vfs_owner', 'string', array('limit' => 255, 'null' => false));
+            $t->column('vfs_data', 'binary');
+            $t->end();
+            $this->addIndex('horde_vfs', array('vfs_path'));
+            $this->addIndex('horde_vfs', array('vfs_name'));
+        }
+        if (!in_array('horde_muvfs', $this->tables())) {
+            $t = $this->createTable('horde_muvfs', array('primaryKey' => array('vfs_id')));
+            $t->column('vfs_id', 'int', array('null' => false, 'unsigned' => true));
+            $t->column('vfs_type', 'smallint', array('null' => false, 'unsigned' => true));
+            $t->column('vfs_path', 'string', array('limit' => 255, 'null' => false));
+            $t->column('vfs_name', 'string', array('limit' => 255, 'null' => false));
+            $t->column('vfs_modified', 'bigint', array('null' => false));
+            $t->column('vfs_owner', 'string', array('limit' => 255, 'null' => false));
+            $t->column('vfs_perms', 'smallint', array('null' => false, 'unsigned' => true));
+            $t->column('vfs_data', 'binary');
+            $t->end();
+            $this->addIndex('horde_muvfs', array('vfs_path'));
+            $this->addIndex('horde_muvfs', array('vfs_name'));
+        }
+    }
+
+    public function down()
+    {
+        $this->dropTable('horde_muvfs');
+        $this->dropTable('horde_vfs');
+    }
+}
diff --git a/framework/VFS/migration/Horde/VFS/2_horde_vfs_upgrade_autoincrement.php b/framework/VFS/migration/Horde/VFS/2_horde_vfs_upgrade_autoincrement.php
new file mode 100644 (file)
index 0000000..b4cf60d
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+class HordeVfsUpgradeAutoIncrement extends Horde_Db_Migration_Base
+{
+    public function up()
+    {
+        $this->changeColumn('horde_vfs', 'vfs_id', 'integer', array('null' => false, 'unsigned' => true, 'default' => null, 'autoincrement' => true));
+        $this->changeColumn('horde_muvfs', 'vfs_id', 'integer', array('null' => false, 'unsigned' => true, 'default' => null, 'autoincrement' => true));
+    }
+
+    public function down()
+    {
+        $this->changeColumn('horde_muvfs', 'vfs_id', 'integer', array('null' => false, 'unsigned' => true));
+        $this->changeColumn('horde_vfs', 'vfs_id', 'integer', array('null' => false, 'unsigned' => true));
+    }
+}
\ No newline at end of file
diff --git a/horde/scripts/sql/horde_muvfs.mssql.sql b/horde/scripts/sql/horde_muvfs.mssql.sql
deleted file mode 100644 (file)
index 4a8e054..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-CREATE TABLE horde_muvfs (
-    vfs_id        INT UNSIGNED NOT NULL,
-    vfs_type      SMALLINT UNSIGNED NOT NULL,
-    vfs_path      VARCHAR(255) NOT NULL,
-    vfs_name      VARCHAR(255) NOT NULL,
-    vfs_modified  BIGINT NOT NULL,
-    vfs_owner     VARCHAR(255) NOT NULL,
-    vfs_perms     SMALLINT UNSIGNED NOT NULL,
-    vfs_data      VARBINARY(MAX),
-    PRIMARY KEY   (vfs_id)
-);
-
-CREATE INDEX vfs_path_idx ON horde_muvfs (vfs_path);
-CREATE INDEX vfs_name_idx ON horde_muvfs (vfs_name);
diff --git a/horde/scripts/sql/horde_muvfs.sql b/horde/scripts/sql/horde_muvfs.sql
deleted file mode 100644 (file)
index 134398c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CREATE TABLE horde_muvfs (
-    vfs_id        INT UNSIGNED NOT NULL,
-    vfs_type      SMALLINT UNSIGNED NOT NULL,
-    vfs_path      VARCHAR(255) NOT NULL,
-    vfs_name      VARCHAR(255) NOT NULL,
-    vfs_modified  BIGINT NOT NULL,
-    vfs_owner     VARCHAR(255) NOT NULL,
-    vfs_perms     SMALLINT UNSIGNED NOT NULL,
-    vfs_data      LONGBLOB,
--- Or, on some DBMS systems:
---  vfs_data      IMAGE,
-    PRIMARY KEY   (vfs_id)
-);
-
-CREATE INDEX vfs_path_idx ON horde_muvfs (vfs_path);
-CREATE INDEX vfs_name_idx ON horde_muvfs (vfs_name);
diff --git a/horde/scripts/sql/horde_vfs.mssql.sql b/horde/scripts/sql/horde_vfs.mssql.sql
deleted file mode 100644 (file)
index 5524b5c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-CREATE TABLE horde_vfs (
-    vfs_id        INT UNSIGNED NOT NULL,
-    vfs_type      SMALLINT UNSIGNED NOT NULL,
-    vfs_path      VARCHAR(255) NOT NULL,
-    vfs_name      VARCHAR(255) NOT NULL,
-    vfs_modified  BIGINT NOT NULL,
-    vfs_owner     VARCHAR(255) NOT NULL,
-    vfs_data      VARBINARY(MAX),
-    PRIMARY KEY   (vfs_id)
-);
-
-CREATE INDEX vfs_path_idx ON horde_vfs (vfs_path);
-CREATE INDEX vfs_name_idx ON horde_vfs (vfs_name);
diff --git a/horde/scripts/sql/horde_vfs.oci8.sql b/horde/scripts/sql/horde_vfs.oci8.sql
deleted file mode 100644 (file)
index 4d96cae..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-CREATE TABLE horde_vfs (
-    vfs_id        NUMBER(16) NOT NULL,
-    vfs_type      NUMBER(8) NOT NULL,
-    vfs_path      VARCHAR2(255),
-    vfs_name      VARCHAR2(255) NOT NULL,
-    vfs_modified  NUMBER(16) NOT NULL,
-    vfs_owner     VARCHAR2(255),
-    vfs_data      BLOB,
---
-    PRIMARY KEY (vfs_id)
-);
-
-CREATE INDEX vfs_path_idx ON horde_vfs (vfs_path);
-CREATE INDEX vfs_name_idx ON horde_vfs (vfs_name);
diff --git a/horde/scripts/sql/horde_vfs.pgsql.sql b/horde/scripts/sql/horde_vfs.pgsql.sql
deleted file mode 100644 (file)
index afecb0b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-CREATE TABLE horde_vfs (
-    vfs_id        INT NOT NULL,
-    vfs_type      SMALLINT NOT NULL,
-    vfs_path      VARCHAR(255) NOT NULL,
-    vfs_name      VARCHAR(255) NOT NULL,
-    vfs_modified  BIGINT NOT NULL,
-    vfs_owner     VARCHAR(255) NOT NULL,
-    vfs_data      TEXT,
-
-    PRIMARY KEY   (vfs_id)
-);
-
-CREATE INDEX vfs_path_idx ON horde_vfs (vfs_path);
-CREATE INDEX vfs_name_idx ON horde_vfs (vfs_name);
diff --git a/horde/scripts/sql/horde_vfs.sql b/horde/scripts/sql/horde_vfs.sql
deleted file mode 100644 (file)
index 1aa8e56..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-CREATE TABLE horde_vfs (
-    vfs_id        INT UNSIGNED NOT NULL,
-    vfs_type      SMALLINT UNSIGNED NOT NULL,
-    vfs_path      VARCHAR(255) NOT NULL,
-    vfs_name      VARCHAR(255) NOT NULL,
-    vfs_modified  BIGINT NOT NULL,
-    vfs_owner     VARCHAR(255) NOT NULL,
-    vfs_data      LONGBLOB,
--- Or, on some DBMS systems:
---  vfs_data      IMAGE,
-    PRIMARY KEY   (vfs_id)
-);
-
-CREATE INDEX vfs_path_idx ON horde_vfs (vfs_path);
-CREATE INDEX vfs_name_idx ON horde_vfs (vfs_name);