Convert Horde_Token to migrations.
authorJan Schneider <jan@horde.org>
Fri, 28 Jan 2011 17:31:56 +0000 (18:31 +0100)
committerJan Schneider <jan@horde.org>
Fri, 28 Jan 2011 18:07:06 +0000 (19:07 +0100)
framework/Token/migration/Horde/Token/1_horde_token_base_tables.php [new file with mode: 0644]
horde/scripts/sql/horde_tokens.sql [deleted file]

diff --git a/framework/Token/migration/Horde/Token/1_horde_token_base_tables.php b/framework/Token/migration/Horde/Token/1_horde_token_base_tables.php
new file mode 100644 (file)
index 0000000..c899528
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+class HordeTokenBaseTables extends Horde_Db_Migration_Base
+{
+    public function up()
+    {
+        if (!in_array('horde_tokens', $this->tables())) {
+            $t = $this->createTable('horde_tokens', array('primaryKey' => array('token_address', 'token_id')));
+            $t->column('token_address', 'string', array('limit' => 100, 'null' => false));
+            $t->column('token_id', 'string', array('limit' => 32, 'null' => false));
+            $t->column('token_timestamp', 'bigint', array('null' => false));
+            $t->end();
+        }
+    }
+
+    public function down()
+    {
+        $this->dropTable('horde_tokens');
+    }
+}
diff --git a/horde/scripts/sql/horde_tokens.sql b/horde/scripts/sql/horde_tokens.sql
deleted file mode 100644 (file)
index 8366b4f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE horde_tokens (
-    token_address    VARCHAR(100) NOT NULL,
-    token_id         VARCHAR(32) NOT NULL,
-    token_timestamp  BIGINT NOT NULL,
---
-    PRIMARY KEY (token_address, token_id)
-);