IMP tables now created via migration script
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 24 May 2010 23:19:02 +0000 (17:19 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 25 May 2010 03:50:53 +0000 (21:50 -0600)
imp/docs/INSTALL
imp/migration/1_imp_base_tables.php [new file with mode: 0644]
imp/scripts/sql/imp.oci8.sql [deleted file]
imp/scripts/sql/imp.sql [deleted file]
imp/scripts/sql/imp.xml [deleted file]

index 7be6169..8288691 100644 (file)
@@ -268,17 +268,11 @@ Configuring IMP
 
 2. Creating the database table
 
-   The specific steps to create the IMP database table depend on which
-   database you've chosen to use.
+   Creating the IMP database table(s) can be accomplished with horde's
+   ``db_migrate`` utility.  If your database is properly setup in the Horde
+   configuration, just run the following:
 
-   First, look in ``scripts/sql/`` to see if a script already exists
-   for your database type.  If so, you should be able to simply execute that
-   script as superuser in your database.  (Note that executing the script as
-   the "horde" user will probably fail when granting privileges.)
-
-   If such a script does not exist, you'll need to build your own, using the
-   file imp.sql as a starting point.  If you need assistance in creating
-   databases, you may wish to let us know on the IMP mailing list.
+      horde/bin/db_migrate imp
 
 3. Configuring IMP
 
diff --git a/imp/migration/1_imp_base_tables.php b/imp/migration/1_imp_base_tables.php
new file mode 100644 (file)
index 0000000..3d788ec
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Create IMP base tables.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  IMP
+ */
+class ImpBaseTables extends Horde_Db_Migration_Base
+{
+    /**
+     * Upgrade.
+     */
+    public function up()
+    {
+        // Create: imp_sentmail
+        $t = $this->createTable('imp_sentmail', array('primaryKey' => 'sentmail_id'));
+        $t->column('sentmail_id', 'integer', array('autoincrement' => true));
+        $t->column('sentmail_who', 'string', array('limit' => 255, 'null' => false));
+        $t->column('sentmail_ts', 'bigint', array('null' => false));
+        $t->column('sentmail_messageid', 'string', array('limit' => 255, 'null' => false));
+        $t->column('sentmail_action', 'string', array('limit' => 32, 'null' => false));
+        $t->column('sentmail_recipient', 'string', array('limit' => 255, 'null' => false));
+        $t->column('sentmail_success', 'integer', array('null' => false));
+        $t->end();
+
+        $this->addIndex('imp_sentmail', array('sentmail_ts'));
+        $this->addIndex('imp_sentmail', array('sentmail_who'));
+        $this->addIndex('imp_sentmail', array('sentmail_success'));
+    }
+
+    /**
+     * Downgrade.
+     */
+    public function down()
+    {
+        $this->dropTable('imp_sentmail');
+    }
+
+}
diff --git a/imp/scripts/sql/imp.oci8.sql b/imp/scripts/sql/imp.oci8.sql
deleted file mode 100644 (file)
index 242eee0..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-CREATE TABLE imp_sentmail (
-    sentmail_id        NUMBER(16) NOT NULL,
-    sentmail_who       VARCHAR2(255) NOT NULL,
-    sentmail_ts        NUMBER(16) NOT NULL,
-    sentmail_messageid VARCHAR2(255) NOT NULL,
-    sentmail_action    VARCHAR2(32) NOT NULL,
-    sentmail_recipient VARCHAR2(255) NOT NULL,
-    sentmail_success   NUMBER(1) NOT NULL,
---
-    PRIMARY KEY (sentmail_id)
-);
-
-CREATE INDEX sentmail_ts_idx ON imp_sentmail (sentmail_ts);
-CREATE INDEX sentmail_who_idx ON imp_sentmail (sentmail_who);
-CREATE INDEX sentmail_success_idx ON imp_sentmail (sentmail_success);
diff --git a/imp/scripts/sql/imp.sql b/imp/scripts/sql/imp.sql
deleted file mode 100644 (file)
index ef896e0..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-CREATE TABLE imp_sentmail (
-    sentmail_id        BIGINT NOT NULL,
-    sentmail_who       VARCHAR(255) NOT NULL,
-    sentmail_ts        BIGINT NOT NULL,
-    sentmail_messageid VARCHAR(255) NOT NULL,
-    sentmail_action    VARCHAR(32) NOT NULL,
-    sentmail_recipient VARCHAR(255) NOT NULL,
-    sentmail_success   INT NOT NULL,
---
-    PRIMARY KEY (sentmail_id)
-);
-
-CREATE INDEX sentmail_ts_idx ON imp_sentmail (sentmail_ts);
-CREATE INDEX sentmail_who_idx ON imp_sentmail (sentmail_who);
-CREATE INDEX sentmail_success_idx ON imp_sentmail (sentmail_success);
diff --git a/imp/scripts/sql/imp.xml b/imp/scripts/sql/imp.xml
deleted file mode 100644 (file)
index 8b6f520..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-
- <name><variable>name</variable></name>
- <create>false</create>
- <overwrite>false</overwrite>
-
- <table>
-
-  <name>imp_sentmail</name>
-
-  <declaration>
-
-   <field>
-    <name>sentmail_id</name>
-    <type>integer</type>
-    <notnull>true</notnull>
-   </field>
-
-   <field>
-    <name>sentmail_who</name>
-    <type>text</type>
-    <length>255</length>
-    <notnull>true</notnull>
-   </field>
-
-   <field>
-    <name>sentmail_ts</name>
-    <type>integer</type>
-    <notnull>true</notnull>
-   </field>
-
-   <field>
-    <name>sentmail_messageid</name>
-    <type>text</type>
-    <length>255</length>
-    <notnull>true</notnull>
-   </field>
-
-   <field>
-    <name>sentmail_action</name>
-    <type>text</type>
-    <length>32</length>
-    <notnull>true</notnull>
-   </field>
-
-   <field>
-    <name>sentmail_recipient</name>
-    <type>text</type>
-    <length>255</length>
-    <notnull>true</notnull>
-   </field>
-
-   <field>
-    <name>sentmail_success</name>
-    <type>integer</type>
-    <length>1</length>
-    <notnull>true</notnull>
-   </field>
-
-   <index>
-    <name>imp_primary</name>
-    <primary>true</primary>
-    <field>
-     <name>sentmail_id</name>
-    </field>
-   </index>
-
-   <index>
-    <name>sentmail_ts</name>
-    <field>
-     <name>sentmail_ts</name>
-     <sorting>ascending</sorting>
-    </field>
-   </index>
-
-   <index>
-    <name>sentmail_who</name>
-    <field>
-     <name>sentmail_who</name>
-     <sorting>ascending</sorting>
-    </field>
-   </index>
-
-   <index>
-    <name>sentmail_success</name>
-    <field>
-     <name>sentmail_success</name>
-     <sorting>ascending</sorting>
-    </field>
-   </index>
-
-  </declaration>
-
- </table>
-
-</database>