Commit 66997f2b authored by mmn's avatar mmn

OStatus classes now has modern schemaDef

parent 3a7261f7
......@@ -78,89 +78,27 @@ class FeedSub extends Managed_DataObject
public $created;
public $modified;
/**
* return table definition for DB_DataObject
*
* DB_DataObject needs to know something about the table to manipulate
* instances. This method provides all the DB_DataObject needs to know.
*
* @return array array of column definitions
*/
function table()
{
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'huburi' => DB_DATAOBJECT_STR,
'secret' => DB_DATAOBJECT_STR,
'verify_token' => DB_DATAOBJECT_STR,
'sub_state' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'last_update' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
}
static function schemaDef()
{
return array(new ColumnDef('id', 'integer',
/*size*/ null,
/*nullable*/ false,
/*key*/ 'PRI',
/*default*/ null,
/*extra*/ null,
/*auto_increment*/ true),
new ColumnDef('uri', 'varchar',
255, false, 'UNI'),
new ColumnDef('huburi', 'text',
null, true),
new ColumnDef('verify_token', 'text',
null, true),
new ColumnDef('secret', 'text',
null, true),
new ColumnDef('sub_state', "enum('subscribe','active','unsubscribe','inactive')",
null, false),
new ColumnDef('sub_start', 'datetime',
null, true),
new ColumnDef('sub_end', 'datetime',
null, true),
new ColumnDef('last_update', 'datetime',
null, false),
new ColumnDef('created', 'datetime',
null, false),
new ColumnDef('modified', 'datetime',
null, false));
}
/**
* return key definitions for DB_DataObject
*
* DB_DataObject needs to know about keys that the table has; this function
* defines them.
*
* @return array key definitions
*/
function keys()
{
return array_keys($this->keyTypes());
}
/**
* return key definitions for Memcached_DataObject
*
* Our caching system uses the same key definitions, but uses a different
* method to get them.
*
* @return array key definitions
*/
function keyTypes()
{
return array('id' => 'K', 'uri' => 'U');
}
function sequenceKey()
public static function schemaDef()
{
return array('id', true, false);
return array(
'fields' => array(
'id' => array('type' => 'int', 'not null' => true, 'description' => 'FeedSub local unique id'),
'uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'FeedSub uri'),
'huburi' => array('type' => 'text', 'description' => 'FeedSub hub-uri'),
'verify_token' => array('type' => 'text', 'description' => 'FeedSub verify-token'),
'secret' => array('type' => 'text', 'description' => 'FeedSub stored secret'),
'sub_state' => array('type' => 'enum("subscribe","active","unsubscribe","inactive")', 'not null' => true, 'description' => 'subscription state'),
'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'),
'sub_end' => array('type' => 'datetime', 'description' => 'subscription end'),
'last_update' => array('type' => 'datetime', 'not null' => true, 'description' => 'when this record was last updated'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'feedsub_uri_key' => array('uri'),
),
);
}
/**
......
......@@ -45,74 +45,25 @@ class HubSub extends Managed_DataObject
return sha1($topic . '|' . $callback);
}
/**
* return table definition for DB_DataObject
*
* DB_DataObject needs to know something about the table to manipulate
* instances. This method provides all the DB_DataObject needs to know.
*
* @return array array of column definitions
*/
function table()
{
return array('hashkey' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'topic' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'callback' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'secret' => DB_DATAOBJECT_STR,
'lease' => DB_DATAOBJECT_INT,
'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
}
static function schemaDef()
{
return array(new ColumnDef('hashkey', 'char',
/*size*/40,
/*nullable*/false,
/*key*/'PRI'),
new ColumnDef('topic', 'varchar',
/*size*/255,
/*nullable*/false,
/*key*/'MUL'),
new ColumnDef('callback', 'varchar',
255, false),
new ColumnDef('secret', 'text',
null, true),
new ColumnDef('lease', 'int',
null, true),
new ColumnDef('sub_start', 'datetime',
null, true),
new ColumnDef('sub_end', 'datetime',
null, true),
new ColumnDef('created', 'datetime',
null, false),
new ColumnDef('modified', 'datetime',
null, false));
}
function keys()
{
return array_keys($this->keyTypes());
}
function sequenceKey()
{
return array(false, false, false);
}
/**
* return key definitions for DB_DataObject
*
* DB_DataObject needs to know about keys that the table has; this function
* defines them.
*
* @return array key definitions
*/
function keyTypes()
public static function schemaDef()
{
return array('hashkey' => 'K');
return array(
'fields' => array(
'hashkey' => array('type' => 'char', 'not null' => true, 'length' => 40, 'description' => 'HubSub hashkey'),
'topic' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'HubSub topic'),
'callback' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'HubSub callback'),
'secret' => array('type' => 'text', 'description' => 'HubSub stored secret'),
'lease' => array('type' => 'int', 'not null' => true, 'description' => 'HubSub leasetime'),
'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'),
'sub_end' => array('type' => 'datetime', 'description' => 'subscription end'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('hashkey'),
'indexes' => array(
'hubsub_topic_idx' => array('topic'),
),
);
}
/**
......
......@@ -32,62 +32,29 @@ class Ostatus_source extends Managed_DataObject
public $notice_id; // notice we're referring to
public $profile_uri; // uri of the ostatus_profile this came through -- may be a group feed
public $method; // push or salmon
public $created;
public $modified;
/**
* return table definition for DB_DataObject
*
* DB_DataObject needs to know something about the table to manipulate
* instances. This method provides all the DB_DataObject needs to know.
*
* @return array array of column definitions
*/
function table()
{
return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'profile_uri' => DB_DATAOBJECT_STR,
'method' => DB_DATAOBJECT_STR);
}
static function schemaDef()
{
return array(new ColumnDef('notice_id', 'integer',
null, false, 'PRI'),
new ColumnDef('profile_uri', 'varchar',
255, false),
new ColumnDef('method', "ENUM('push','salmon')",
null, false));
}
/**
* return key definitions for DB_DataObject
*
* DB_DataObject needs to know about keys that the table has; this function
* defines them.
*
* @return array key definitions
*/
function keys()
public static function schemaDef()
{
return array_keys($this->keyTypes());
}
/**
* return key definitions for Memcached_DataObject
*
* Our caching system uses the same key definitions, but uses a different
* method to get them.
*
* @return array key definitions
*/
function keyTypes()
{
return array('notice_id' => 'K');
}
function sequenceKey()
{
return array(false, false, false);
}
return array(
'fields' => array(
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'Notice ID relation'),
'profile_uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'Profile URI'),
'method' => array('type' => 'enum("push","salmon")', 'not null' => true, 'description' => 'source method'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('notice_id'),
'foreign keys' => array(
'ostatus_source_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
// not in profile table yet 'ostatus_source_profile_uri_fkey' => array('profile', array('profile_uri' => 'uri')),
),
'indexes' => array(
'ostatus_source_profile_uri_idx' => array('profile_uri'),
),
);
}
/**
* Save a remote notice source record; this helps indicate how trusted we are.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment