Magicsig class now Managed_DataObject with nicer schemaDef
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 18 Aug 2013 13:31:18 +0000 (15:31 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 18 Aug 2013 13:31:18 +0000 (15:31 +0200)
plugins/OStatus/classes/Magicsig.php

index 01c4689676ec903dc901a81e0a7c079a17cc1bec..4a703ae3b784f28009cbbd26e4f400cb8c04b7c1 100644 (file)
@@ -81,39 +81,21 @@ class Magicsig extends Managed_DataObject
         $this->alg = $alg;
     }
 
-    function table()
+    public static function schemaDef()
     {
         return array(
-            'user_id' => DB_DATAOBJECT_INT,
-            'keypair' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
-            'alg'     => DB_DATAOBJECT_STR
+            'fields' => array(
+                'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
+                'keypair' => array('type' => 'text', 'description' => 'keypair text representation', 'collate' => 'utf8_general_ci'),
+                'alg' => array('type' => 'varchar', 'length' => 64, 'description' => 'algorithm'),
+            ),
+            'primary key' => array('user_id'),
+            'foreign keys' => array(
+                'magicsig_user_id_fkey' => array('user', array('user_id' => 'id')),
+            ),
         );
     }
 
-    static function schemaDef()
-    {
-        return array(new ColumnDef('user_id', 'integer',
-                                   null, false, 'PRI'),
-                     new ColumnDef('keypair', 'text',
-                                   false, false),
-                     new ColumnDef('alg', 'varchar',
-                                   64, false));
-    }
-
-    function keys()
-    {
-        return array_keys($this->keyTypes());
-    }
-
-    function keyTypes()
-    {
-        return array('user_id' => 'K');
-    }
-
-    function sequenceKey() {
-        return array(false, false, false);
-    }
-
     /**
      * Save this keypair into the database.
      *