Add a migration script for creating the tables in rampage_base.xml with Horde_Db
authorChuck Hagenbuch <chuck@horde.org>
Sat, 9 Jan 2010 04:11:35 +0000 (23:11 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Sat, 9 Jan 2010 04:12:54 +0000 (23:12 -0500)
instead of with MDB2_Schema. Should be a bit easier to make work and to get
going.

This currently works, if you have content set up in registry.php, by running:
$ db_migrate -a content

content/migrations/1_rampage_base_tables.php [new file with mode: 0644]

diff --git a/content/migrations/1_rampage_base_tables.php b/content/migrations/1_rampage_base_tables.php
new file mode 100644 (file)
index 0000000..b2ea87d
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+class RampageBaseTables extends Horde_Db_Migration_Base
+{
+    public function up()
+    {
+        // rampage_types
+        $t = $this->createTable('rampage_types', array('primaryKey' => false));
+          $t->column('type_id',   'primaryKey');
+          $t->column('type_name', 'string', array('limit' => 255, 'null' => false));
+        $t->end();
+
+        $this->addIndex('rampage_types', array('type_name'), array('name' => 'rampage_objects_type_name', 'unique' => true));
+
+        // rampage_objects
+        $t = $this->createTable('rampage_objects', array('primaryKey' => false));
+          $t->column('object_id',   'primaryKey');
+          $t->column('object_name', 'string',  array('limit' => 255, 'null' => false));
+          $t->column('type_id',     'integer', array('null' => false, 'unsigned' => true));
+        $t->end();
+
+        $this->addIndex('rampage_objects', array('type_id', 'object_name'), array('name' => 'rampage_objects_type_object_name', 'unique' => true));
+
+        // rampage_users
+        $t = $this->createTable('rampage_users', array('primaryKey' => false));
+          $t->column('user_id',   'primaryKey');
+          $t->column('user_name', 'string', array('limit' => 255, 'null' => false));
+        $t->end();
+
+        $this->addIndex('rampage_users', array('user_name'), array('name' => 'rampage_users_user_name', 'unique' => true));
+    }
+
+    public function down()
+    {
+        $this->dropTable('rampage_types');
+        $this->dropTable('rampage_objects');
+        $this->dropTable('rampage_users');
+    }
+}