/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+ public static function schemaDef()
+ {
+ return array(
+ 'fields' => array(
+ 'provider_name' => array('type' => 'varchar', 'length' => 255, 'description' => 'provider name'),
+ 'username' => array('type' => 'varchar', 'length' => 255, 'description' => 'username'),
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
+ '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('provider_name', 'username'),
+ 'foreign keys' => array(
+ 'user_username_user_id_fkey' => array('user', array('user_id' => 'id')),
+ ),
+ );
+ }
+
/**
* Register a user with a username on a given provider
* @param User User object
return false;
}
}
-
- function table() {
- return array(
- 'user_id' => DB_DATAOBJECT_INT,
- 'username' => DB_DATAOBJECT_STR,
- 'provider_name' => DB_DATAOBJECT_STR ,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
- );
- }
-
- // now define the keys.
- function keys() {
- return array('provider_name' => 'K', 'username' => 'K');
- }
}
function onCheckSchema() {
$schema = Schema::get();
- $schema->ensureTable('user_username',
- array(new ColumnDef('provider_name', 'varchar',
- '255', false, 'PRI'),
- new ColumnDef('username', 'varchar',
- '255', false, 'PRI'),
- new ColumnDef('user_id', 'integer',
- null, false),
- new ColumnDef('created', 'datetime',
- null, false),
- new ColumnDef('modified', 'timestamp')));
+ $schema->ensureTable('user_username', User_username::schemaDef());
return true;
}
$schema = Schema::get();
// For storing total number of times a notice has been faved
-
- $schema->ensureTable('fave_tally',
- array(
- new ColumnDef('notice_id', 'integer', null, false, 'PRI'),
- new ColumnDef('count', 'integer', null, false),
- new ColumnDef(
- 'modified',
- 'timestamp',
- null,
- false,
- null,
- 'CURRENT_TIMESTAMP',
- 'on update CURRENT_TIMESTAMP'
- )
- )
- );
+ $schema->ensureTable('fave_tally', Fave_tally::schemaDef());
return true;
}
public $__table = 'fave_tally'; // table name
public $notice_id; // int(4) primary_key not_null
public $count; // int(4) not_null
+ public $created; // datetime() not_null
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- /**
- * return table definition for DB_DataObject
- *
- * @return array array of column definitions
- */
-
- function table()
+ public static function schemaDef()
{
return array(
- 'notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'count' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL
+ 'fields' => array(
+ 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id'),
+ 'count' => array('type' => 'int', 'not null' => true, 'description' => 'the fave tally count'),
+ '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(
+ 'fave_tally_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
+ ),
);
}
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- 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. This key information is used to store and clear
- * cached data, so be sure to list any key that will be used for static
- * lookups.
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('notice_id' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * If a table has a single integer column as its primary key, DB_DataObject
- * assumes that the column is auto-incrementing and makes a sequence table
- * to do this incrementation. Since we don't need this for our class, we
- * overload this method and return the magic formula that DB_DataObject needs.
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
- {
- return array(false, false, false);
- }
-
/**
* Increment a notice's tally
*
$schema = Schema::get();
// For storing blacklist patterns for nicknames
- $schema->ensureTable('nickname_blacklist',
- array(new ColumnDef('pattern',
- 'varchar',
- 255,
- false,
- 'PRI'),
- new ColumnDef('created',
- 'datetime',
- null,
- false)));
-
- $schema->ensureTable('homepage_blacklist',
- array(new ColumnDef('pattern',
- 'varchar',
- 255,
- false,
- 'PRI'),
- new ColumnDef('created',
- 'datetime',
- null,
- false)));
+ $schema->ensureTable('nickname_blacklist', Nickname_blacklist::schemaDef());
+ $schema->ensureTable('homepage_blacklist', Homepage_blacklist::schemaDef());
return true;
}
class Homepage_blacklist extends Managed_DataObject
{
public $__table = 'homepage_blacklist'; // table name
- public $pattern; // string pattern
- public $created; // datetime
+ public $pattern; // varchar(255) pattern
+ public $created; // datetime not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * 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('pattern' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
- }
-
- /**
- * 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()
+ public static function schemaDef()
{
- return array('pattern' => 'K');
+ return array(
+ 'fields' => array(
+ 'pattern' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'blacklist pattern'),
+ '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('pattern'),
+ );
}
/**
class Nickname_blacklist extends Managed_DataObject
{
public $__table = 'nickname_blacklist'; // table name
- public $pattern; // string pattern
- public $created; // datetime
+ public $pattern; // varchar(255) pattern
+ public $created; // datetime not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * return table definition for DB_DataObject
- *
- * @return array array of column definitions
- */
- function table()
- {
- return array('pattern' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * @return array key definitions
- */
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- /**
- * return key definitions for Memcached_DataObject
- *
- * @return array key definitions
- */
- function keyTypes()
+ public static function schemaDef()
{
- return array('pattern' => 'K');
+ return array(
+ 'fields' => array(
+ 'pattern' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'blacklist pattern'),
+ '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('pattern'),
+ );
}
/**
$schema = Schema::get();
// For storing user-submitted flags on profiles
- $schema->ensureTable('email_summary_status',
- array(new ColumnDef('user_id', 'integer', null,
- false, 'PRI'),
- new ColumnDef('send_summary', 'tinyint', null,
- false, null, 1),
- new ColumnDef('last_summary_id', 'integer', null,
- true),
- new ColumnDef('created', 'datetime', null,
- false),
- new ColumnDef('modified', 'datetime', null,
- false),
- )
- );
+ $schema->ensureTable('email_summary_status', Email_summary_status::schemaDef());
return true;
}
public $created; // datetime not_null
public $modified; // datetime not_null
- /**
- * 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('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'send_summary' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'last_summary_id' => DB_DATAOBJECT_INT,
- 'created' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
- 'modified' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * @return array list of key field names
- */
- 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. This key information is used to store and clear
- * cached data, so be sure to list any key that will be used for static
- * lookups.
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('user_id' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
+ public static function schemaDef()
{
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
+ 'send_summary' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'not null' => true, 'description' => 'whether to send a summary or not'),
+ 'last_summary_id' => array('type' => 'int', 'description' => 'last summary id'),
+ '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('user_id'),
+ 'foreign keys' => array(
+ 'email_summary_status_user_id_fkey' => array('user', array('user_id' => 'id')),
+ ),
+ );
}
/**
$schema = Schema::get();
// For storing user-submitted flags on profiles
- $schema->ensureTable('user_followeveryone_prefs',
- array(new ColumnDef('user_id', 'integer', null,
- true, 'PRI'),
- new ColumnDef('followeveryone', 'tinyint', null,
- false, null, 1)));
+ $schema->ensureTable('user_followeveryone_prefs', User_followeveryone_prefs::schemaDef());
return true;
}
public $__table = 'user_followeveryone_prefs'; // table name
public $user_id; // int(4) primary_key not_null
public $followeveryone; // tinyint(1)
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * 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()
+ public static function schemaDef()
{
- return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'followeveryone' => DB_DATAOBJECT_INT + DB_DATAOBJECT_BOOL);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- 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. This key information is used to store and clear
- * cached data, so be sure to list any key that will be used for static
- * lookups.
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('user_id' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * If a table has a single integer column as its primary key, DB_DataObject
- * assumes that the column is auto-incrementing and makes a sequence table
- * to do this incrementation. Since we don't need this for our class, we
- * overload this method and return the magic formula that DB_DataObject needs.
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
- {
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
+ 'followeveryone' => array('type' => 'int', 'default' => 1, 'size' => 'tiny', 'description' => 'whether to follow everyone'),
+ '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('user_id'),
+ 'foreign keys' => array(
+ 'user_followeveryone_prefs_user_id_fkey' => array('user', array('user_id' => 'id')),
+ ),
+ );
}
static function followEveryone($user_id)
function onCheckSchema()
{
$schema = Schema::get();
- $schema->ensureTable('GNUsocialPhoto',
- array(new ColumnDef('id', 'int(11)', null, false, 'PRI', null, null, true),
- new ColumnDef('notice_id', 'int(11)', null, false),
- new ColumnDef('album_id', 'int(11)', null, false),
- new ColumnDef('uri', 'varchar(512)', null, false),
- new ColumnDef('thumb_uri', 'varchar(512)', null, false),
- new ColumnDef('title', 'varchar(512)', null, false),
- new ColumnDef('photo_description', 'text', null, false)));
- $schema->ensureTable('GNUsocialPhotoAlbum',
- array(new ColumnDef('album_id', 'int(11)', null, false, 'PRI', null, null, true),
- new ColumnDef('profile_id', 'int(11)', null, false),
- new ColumnDef('album_name', 'varchar(256)', null, false),
- new ColumnDef('album_description', 'text', null, false)));
-
+ $schema->ensureTable('GNUsocialPhoto', GNUsocialPhoto::schemaDef());
+ $schema->ensureTable('GNUsocialPhotoAlbum', GNUsocialPhotoAlbum::schemaDef());
}
function onRouterInitialized($m)
public $id; // int(11)
public $notice_id; // int(11)
public $album_id; // int(11)
- public $uri; // varchar(512)
- public $thumb_uri; // varchar(512)
- public $title; // varchar(512)
+ public $uri; // varchar(255)
+ public $thumb_uri; // varchar(255)
+ public $title; // varchar(255)
public $photo_description; // text
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* function delete()
{
return parent::delete();
} */
-
- /*
- * TODO: Foriegn key on album_id.
- */
- function table()
- {
- return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'album_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'thumb_uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'title' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'photo_description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
- }
-
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- function keyTypes()
- {
- return array('notice_id' => 'K');
- }
-
- function sequenceKey()
+ public static function schemaDef()
{
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for Photo'),
+ 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'Notice ID for the related notice'),
+ 'album_id' => array('type' => 'int', 'not null' => true, 'description' => 'The parent album ID'),
+ 'uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'unique address for this photo'),
+ 'thumb_uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'unique address for this photo thumbnail'),
+ 'title' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'The Photo title'),
+ 'photo_description' => array('type' => 'text', 'not null' => true, 'description' => 'A description for this photo'),
+ '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(
+ 'gnusocialphoto_uri' => array('uri'),
+ ),
+ 'foreign keys' => array(
+ 'gnusocialphoto_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
+ 'gnusocialphoto_album_id_fkey' => array('GNUsocialPhotoAlbum', array('album_id' => 'id')),
+ ),
+ 'indexes' => array(
+ 'gnusocialphoto_title_idx' => array('title'),
+ ),
+ );
}
function saveNew($profile_id, $album_id, $thumb_uri, $uri, $source, $insert_now, $title = null, $photo_description = null)
public $__table = 'GNUsocialPhotoAlbum';
public $album_id; // int(11) -- Unique identifier for the album
public $profile_id; // int(11) -- Profile ID for the owner of the album
- public $album_name; // varchar(256) -- Title for this album
+ public $album_name; // varchar(255) -- Title for this album
public $album_description; // text -- A description of the album
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* TODO: Primary key on both album_id, profile_id / foriegn key on profile_id */
- function table()
+ public static function schemaDef()
{
- return array('album_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'album_name' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'album_description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
- }
-
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
-
- /* Using album_id as the primary key for now.. */
- function keyTypes()
- {
- return array('album_id' => 'K');
- }
-
- function sequenceKey()
- {
- return array('album_id', true, false);
+ return array(
+ 'fields' => array(
+ 'album_id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique identifier for the album'),
+ 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'Profile ID for the owner of the album'),
+ 'album_name' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'Title for this album'),
+ 'album_description' => array('type' => 'text', 'not null' => true, 'description' => 'A description for this album'),
+ '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('user_id'),
+ 'foreign keys' => array(
+ 'gnusocialphotoalbum_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
+ ),
+ 'indexes' => array(
+ 'gnusocialphotoalbum_album_name_idx' => array('album_name'),
+ ),
+ );
}
function getPageLink()
function onCheckSchema()
{
$schema = Schema::get();
- $schema->ensureTable('GNUsocialProfileExtensionField',
- array(new ColumnDef('id', 'int(11)', null, false, 'PRI', null, null, true),
- new ColumnDef('systemname', 'varchar(64)', null, false),
- new ColumnDef('title', 'varchar(256)', null, false),
- new ColumnDef('description', 'text', null, false),
- new ColumnDef('type', 'varchar(256)', null, false)));
- $schema->ensureTable('GNUsocialProfileExtensionResponse',
- array(new ColumnDef('id', 'int(11)', null, false, 'PRI', null, null, true),
- new ColumnDef('extension_id', 'int(11)', null, false),
- new ColumnDef('profile_id', 'int(11)', null, false),
- new ColumnDef('value', 'text', null, false)));
+ $schema->ensureTable('GNUsocialProfileExtensionField', GNUsocialProfileExtensionField::schemaDef());
+ $schema->ensureTable('GNUsocialProfileExtensionResponse', GNUsocialProfileExtensionResponse::schemaDef());
}
public $__table = 'GNUsocialProfileExtensionField';
public $id; // int(11)
public $systemname; // varchar(64)
- public $title; // varchar(256)
+ public $title; // varchar(255)
public $description; // text
- public $type; // varchar(256)
+ public $type; // varchar(255)
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- function table()
+ public static function schemaDef()
{
- return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'systemname' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'title' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'type' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
- }
-
- function keys()
- {
- return array_keys($this->keyTypes());
+ return array(
+ 'fields' => array(
+ 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension field'),
+ 'systemname' => array('type' => 'varchar', 'not null' => true, 'length' => 64, 'description' => 'field systemname'),
+ 'title' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'field title'),
+ 'description' => array('type' => 'text', 'not null' => true, 'description' => 'field description'),
+ 'type' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'field type'),
+ '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'),
+ 'indexes' => array(
+ 'gnusocialprofileextensionfield_title_idx' => array('title'),
+ ),
+ );
}
function keyTypes()
public $extension_id; // int(11)
public $profile_id; // int(11)
public $value; // text
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- function table()
+ public static function schemaDef()
{
- return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'extension_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'value' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
- }
-
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- function keyTypes()
- {
- return array('id' => 'K');
- }
-
- function sequenceKey()
- {
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension response'),
+ 'extension_id' => array('type' => 'int', 'not null' => true, 'description' => 'The extension field ID'),
+ 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'Profile id that made the response'),
+ 'value' => array('type' => 'text', 'not null' => true, 'description' => 'response entry'),
+ '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'),
+ 'foreign keys' => array(
+ 'gnusocialprofileextensionresponse_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
+ 'gnusocialprofileextensionresponse_extension_id_fkey' => array('GNUsocialProfileExtensionField', array('extension_id' => 'id')),
+ ),
+ 'indexes' => array(
+ 'gnusocialprofileextensionresponse_extension_id_idx' => array('extension_id'),
+ ),
+ );
}
static function newResponse($extension_id, $profile_id, $value)
$schema = Schema::get();
// For storing user-submitted flags on profiles
-
- $schema->ensureTable('group_privacy_settings',
- array(new ColumnDef('group_id',
- 'integer',
- null,
- false,
- 'PRI'),
- new ColumnDef('allow_privacy',
- 'integer'),
- new ColumnDef('allow_sender',
- 'integer'),
- new ColumnDef('created',
- 'datetime'),
- new ColumnDef('modified',
- 'timestamp')));
-
- $schema->ensureTable('group_message',
- array(new ColumnDef('id',
- 'char',
- 36,
- false,
- 'PRI'),
- new ColumnDef('uri',
- 'varchar',
- 255,
- false,
- 'UNI'),
- new ColumnDef('from_profile',
- 'integer',
- null,
- false,
- 'MUL'),
- new ColumnDef('to_group',
- 'integer',
- null,
- false,
- 'MUL'),
- new ColumnDef('content',
- 'text'),
- new ColumnDef('rendered',
- 'text'),
- new ColumnDef('url',
- 'varchar',
- 255,
- false,
- 'UNI'),
- new ColumnDef('created',
- 'datetime')));
-
- $schema->ensureTable('group_message_profile',
- array(new ColumnDef('to_profile',
- 'integer',
- null,
- false,
- 'PRI'),
- new ColumnDef('group_message_id',
- 'char',
- 36,
- false,
- 'PRI'),
- new ColumnDef('created',
- 'datetime')));
-
+ $schema->ensureTable('group_privacy_settings', Group_privacy_settings::schemaDef());
+ $schema->ensureTable('group_message', Group_message::schemaDef());
+ $schema->ensureTable('group_message_profile', Group_message_profile::schemaDef());
return true;
}
class Group_message extends Managed_DataObject
{
public $__table = 'group_message'; // table name
- public $id; // char(36) primary_key not_null
+ public $id; // varchar(36) primary_key not_null
public $uri; // varchar(255)
public $from_profile; // int
public $to_group; // int
public $content;
public $rendered;
public $url;
- public $created;
-
- /**
- * 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_STR + DB_DATAOBJECT_NOTNULL,
- 'uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'from_profile' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'to_group' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'content' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'rendered' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'url' => DB_DATAOBJECT_STR,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- function keys()
- {
- return array_keys($this->keyTypes());
- }
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * return key definitions for Memcached_DataObject
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
+ public static function schemaDef()
{
- return array('id' => 'K', 'uri' => 'U');
+ return array(
+ 'fields' => array(
+ 'id' => array('type' => 'varchar', 'not null' => true, 'length' => 36, 'description' => 'message uuid'),
+ 'uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'message uri'),
+ 'url' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'representation url'),
+ 'from_profile' => array('type' => 'int', 'not null' => true, 'description' => 'sending profile ID'),
+ 'to_group' => array('type' => 'int', 'not null' => true, 'description' => 'receiving group ID'),
+ 'content' => array('type' => 'text', 'not null' => true, 'description' => 'message content'),
+ 'rendered' => array('type' => 'text', 'not null' => true, 'description' => 'rendered message'),
+ '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(
+ 'group_message_uri_key' => array('uri'),
+ ),
+ 'foreign keys' => array(
+ 'group_message_from_profile_fkey' => array('profile', array('from_profile' => 'id')),
+ 'group_message_to_group_fkey' => array('user_group', array('to_group' => 'id')),
+ ),
+ 'indexes' => array(
+ 'group_message_from_profile_idx' => array('from_profile'),
+ 'group_message_to_group_idx' => array('to_group'),
+ 'group_message_url_idx' => array('url'),
+ ),
+ );
}
static function send($user, $group, $text)
{
public $__table = 'group_message_profile'; // table name
public $to_profile; // int
- public $group_message_id; // char(36) primary_key not_null
- public $created;
-
- /**
- * 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('to_profile' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'group_message_id' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- /**
- * return key definitions for Memcached_DataObject
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('to_profile' => 'K', 'group_message_id' => 'K');
- }
+ public $group_message_id; // varchar(36) primary_key not_null
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * No sequence keys in this table.
- */
- function sequenceKey()
+ public static function schemaDef()
{
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'to_profile' => array('type' => 'int', 'not null' => true, 'description' => 'id of group direct message'),
+ 'group_message_id' => array('type' => 'varchar', 'not null' => true, 'length' => 36, 'description' => 'group message uuid'),
+ '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('to_profile', 'group_message_id'),
+ 'foreign keys' => array(
+ 'group_message_profile_to_profile_fkey' => array('profile', array('to_profile' => 'id')),
+ 'group_message_profile_group_message_id_fkey' => array('group_message', array('group_message_id' => 'id')),
+ ),
+ );
}
function send($gm, $profile)
const MEMBER = 2;
const ADMIN = 4;
- /**
- * 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()
+ public static function schemaDef()
{
- return array('group_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'allow_privacy' => DB_DATAOBJECT_INT,
- 'allow_sender' => DB_DATAOBJECT_INT,
- '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);
-
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- /**
- * return key definitions for Memcached_DataObject
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('group_id' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
- {
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group_privacy_settings'),
+ 'allow_privacy' => array('type' => 'int', 'not null' => true, 'description' => 'sometimes=-1, never=0, always=1'),
+ 'allow_sender' => array('type' => 'int', 'not null' => true, 'description' => 'list of bit-mappy values in source code'),
+ '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('group_id'),
+ 'foreign keys' => array(
+ 'group_privacy_settings_group_id_fkey' => array('user_group', array('group_id' => 'id')),
+ ),
+ );
}
function forGroup($group)
$schema = Schema::get();
// For storing messages while sessions become ready
- $schema->ensureTable('irc_waiting_message',
- array(new ColumnDef('id', 'integer', null,
- false, 'PRI', null, null, true),
- new ColumnDef('data', 'blob', null, false),
- new ColumnDef('prioritise', 'tinyint', 1, false),
- new ColumnDef('attempts', 'integer', null, false),
- new ColumnDef('created', 'datetime', null, false),
- new ColumnDef('claimed', 'datetime')));
-
+ $schema->ensureTable('irc_waiting_message', Irc_waiting_message::schemaDef());
return true;
}
public $data; // blob not_null\r
public $prioritise; // tinyint(1) not_null\r
public $attempts; // int not_null\r
- public $created; // datetime() not_null\r
public $claimed; // datetime()\r
-\r
- /**\r
- * return table definition for DB_DataObject\r
- *\r
- * DB_DataObject needs to know something about the table to manipulate\r
- * instances. This method provides all the DB_DataObject needs to know.\r
- *\r
- * @return array array of column definitions\r
- */\r
- public function table() {\r
- return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,\r
- 'data' => DB_DATAOBJECT_BLOB + DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
- 'prioritise' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,\r
- 'created' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
- 'claimed' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR);\r
- }\r
-\r
- /**\r
- * return key definitions for DB_DataObject\r
- *\r
- * DB_DataObject needs to know about keys that the table has, since it\r
- * won't appear in StatusNet's own keys list. In most cases, this will\r
- * simply reference your keyTypes() function.\r
- *\r
- * @return array list of key field names\r
- */\r
- public function keys() {\r
- return array_keys($this->keyTypes());\r
- }\r
-\r
- /**\r
- * return key definitions for Memcached_DataObject\r
- *\r
- * Our caching system uses the same key definitions, but uses a different\r
- * method to get them. This key information is used to store and clear\r
- * cached data, so be sure to list any key that will be used for static\r
- * lookups.\r
- *\r
- * @return array associative array of key definitions, field name to type:\r
- * 'K' for primary key: for compound keys, add an entry for each component;\r
- * 'U' for unique keys: compound keys are not well supported here.\r
- */\r
- public function keyTypes() {\r
- return array('id' => 'K');\r
- }\r
-\r
- /**\r
- * Magic formula for non-autoincrementing integer primary keys\r
- *\r
- * If a table has a single integer column as its primary key, DB_DataObject\r
- * assumes that the column is auto-incrementing and makes a sequence table\r
- * to do this incrementation. Since we don't need this for our class, we\r
- * overload this method and return the magic formula that DB_DataObject needs.\r
- *\r
- * @return array magic three-false array that stops auto-incrementing.\r
- */\r
- public function sequenceKey() {\r
- return array(false, false, false);\r
+ public $created; // datetime() not_null\r
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP\r
+\r
+ public static function schemaDef()\r
+ {\r
+ return array(\r
+ 'fields' => array(\r
+ 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for entry'),\r
+ 'data' => array('type' => 'blob', 'not null' => true, 'description' => 'data blob'),\r
+ 'prioritise' => array('type' => 'int', 'size' => 'tiny', 'description' => 'tinyint priority value'),\r
+ 'attempts' => array('type' => 'int', 'not null' => true, 'description' => 'attempts count'),\r
+ 'claimed' => array('type' => 'datetime', 'description' => 'date this irc message was claimed'),\r
+ 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),\r
+ 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),\r
+ ),\r
+ 'primary key' => array('id'),\r
+ 'indexes' => array(\r
+ 'irc_waiting_message_prioritise_idx' => array('prioritise'),\r
+ ),\r
+ );\r
}\r
\r
/**\r
$schema = Schema::get();\r
\r
// For storing messages while sessions become ready\r
- $schema->ensureTable('msn_waiting_message',\r
- array(new ColumnDef('id', 'integer', null,\r
- false, 'PRI', null, null, true),\r
- new ColumnDef('screenname', 'varchar', 255, false),\r
- new ColumnDef('message', 'text', null, false),\r
- new ColumnDef('created', 'datetime', null, false),\r
- new ColumnDef('claimed', 'datetime')));\r
-\r
+ $schema->ensureTable('msn_waiting_message', Msn_waiting_message::schemaGet());\r
return true;\r
}\r
\r
public $id; // int primary_key not_null auto_increment\r
public $screenname; // varchar(255) not_null\r
public $message; // text not_null\r
- public $created; // datetime() not_null\r
public $claimed; // datetime()\r
+ public $created; // datetime() not_null\r
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP\r
\r
- /**\r
- * return table definition for DB_DataObject\r
- *\r
- * DB_DataObject needs to know something about the table to manipulate\r
- * instances. This method provides all the DB_DataObject needs to know.\r
- *\r
- * @return array array of column definitions\r
- */\r
- public function table() {\r
- return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,\r
- 'screenname' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
- 'message' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
- 'created' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
- 'claimed' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR);\r
- }\r
-\r
- /**\r
- * return key definitions for DB_DataObject\r
- *\r
- * DB_DataObject needs to know about keys that the table has, since it\r
- * won't appear in StatusNet's own keys list. In most cases, this will\r
- * simply reference your keyTypes() function.\r
- *\r
- * @return array list of key field names\r
- */\r
- public function keys() {\r
- return array_keys($this->keyTypes());\r
- }\r
-\r
- /**\r
- * return key definitions for Memcached_DataObject\r
- *\r
- * Our caching system uses the same key definitions, but uses a different\r
- * method to get them. This key information is used to store and clear\r
- * cached data, so be sure to list any key that will be used for static\r
- * lookups.\r
- *\r
- * @return array associative array of key definitions, field name to type:\r
- * 'K' for primary key: for compound keys, add an entry for each component;\r
- * 'U' for unique keys: compound keys are not well supported here.\r
- */\r
- public function keyTypes() {\r
- return array('id' => 'K');\r
- }\r
-\r
- /**\r
- * Magic formula for non-autoincrementing integer primary keys\r
- *\r
- * If a table has a single integer column as its primary key, DB_DataObject\r
- * assumes that the column is auto-incrementing and makes a sequence table\r
- * to do this incrementation. Since we don't need this for our class, we\r
- * overload this method and return the magic formula that DB_DataObject needs.\r
- *\r
- * @return array magic three-false array that stops auto-incrementing.\r
- */\r
- function sequenceKey() {\r
- return array(false, false, false);\r
+ public static function schemaDef()\r
+ {\r
+ return array(\r
+ 'fields' => array(\r
+ 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for entry'),\r
+ 'screenname' => array('type' => 'varchar', 'length' => 255, 'description' => 'from screenname'),\r
+ 'message' => array('type' => 'text', 'not null' => true, 'description' => 'MSN message text'),\r
+ 'claimed' => array('type' => 'datetime', 'description' => 'date this irc message was claimed'),\r
+ 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),\r
+ 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),\r
+ ),\r
+ 'primary key' => array('id'),\r
+ 'indexes' => array(\r
+ 'msn_waiting_message_prioritise_idx' => array('screenname'),\r
+ ),\r
+ );\r
}\r
\r
/**\r
$schema = Schema::get();
// For storing titles for notices
-
- $schema->ensureTable('notice_title',
- array(new ColumnDef('notice_id',
- 'integer',
- null,
- true,
- 'PRI'),
- new ColumnDef('title',
- 'varchar',
- Notice_title::MAXCHARS,
- false)));
-
+ $schema->ensureTable('notice_title', Notice_title::schemaDef());
return true;
}
const MAXCHARS = 255;
public $__table = 'notice_title'; // table name
- public $notice_id; // int(4) primary_key not_null
+ public $notice_id; // int(11) primary_key not_null
public $title; // varchar(255)
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * 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,
- 'title' => DB_DATAOBJECT_STR);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * @return array list of key field names
- */
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- /**
- * return key definitions for Memcached_DataObject
- *
- * @return array list mapping field names to key types
- */
- function keyTypes()
- {
- return array('notice_id' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
+ public static function schemaDef()
{
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
+ 'title' => array('type' => 'varchar', 'length' => Notice_title::MAXCHARS, 'description' => 'title to notice'),
+ '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(
+ 'notice_title_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
+ ),
+ );
}
/**
function onCheckSchema()
{
$schema = Schema::get();
- $schema->ensureTable('user_openid',
- array(new ColumnDef('canonical', 'varchar',
- '255', false, 'PRI'),
- new ColumnDef('display', 'varchar',
- '255', false, 'UNI'),
- new ColumnDef('user_id', 'integer',
- null, false, 'MUL'),
- new ColumnDef('created', 'datetime',
- null, false),
- new ColumnDef('modified', 'timestamp')));
- $schema->ensureTable('user_openid_trustroot',
- array(new ColumnDef('trustroot', 'varchar',
- '255', false, 'PRI'),
- new ColumnDef('user_id', 'integer',
- null, false, 'PRI'),
- new ColumnDef('created', 'datetime',
- null, false),
- new ColumnDef('modified', 'timestamp')));
-
+ $schema->ensureTable('user_openid', User_openid::schemaDef());
+ $schema->ensureTable('user_openid_trustroot', User_openid_trustroot::schemaDef());
$schema->ensureTable('user_openid_prefs', User_openid_prefs::schemaDef());
/* These are used by JanRain OpenID library */
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function table()
+ public static function schemaDef()
{
- $db = $this->getDatabaseConnection();
- $dbtype = $db->phptype; // Database type is stored here. Crazy but true.
-
- return array('canonical' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'display' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
- 'modified' => ($dbtype == 'mysql' || $dbtype == 'mysqli') ?
- DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL :
- DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
- );
- }
-
- /**
- * List primary and unique keys in this table.
- * Unique keys used for lookup *MUST* be listed to ensure proper caching.
- */
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- function keyTypes()
- {
- return array('canonical' => 'K', 'display' => 'U', 'user_id' => 'U');
- }
-
- /**
- * No sequence keys in this table.
- */
- function sequenceKey()
- {
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'canonical' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'OpenID canonical string'),
+ 'display' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'OpenID display string'),
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'User ID for OpenID owner'),
+ '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('canonical'),
+ 'unique keys' => array(
+ 'user_openid_display_key' => array('display'),
+ ),
+ 'indexes' => array(
+ 'user_openid_user_id_idx' => array('user_id'),
+ ),
+ 'foreign keys' => array(
+ 'user_openid_user_id_fkey' => array('user', array('user_id' => 'id')),
+ ),
+ );
}
static function hasOpenID($user_id)
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function table()
+ public static function schemaDef()
{
- $db = $this->getDatabaseConnection();
- $dbtype = $db->phptype; // Database type is stored here. Crazy but true.
-
- return array('trustroot' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
- 'modified' => ($dbtype == 'mysql' || $dbtype == 'mysqli') ?
- DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL :
- DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
- );
- }
-
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- function keyTypes()
- {
- return array('trustroot' => 'K', 'user_id' => 'K');
+ return array(
+ 'fields' => array(
+ 'trustroot' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'OpenID trustroot string'),
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'User ID for OpenID trustroot owner'),
+ '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('trustroot', 'user_id'),
+ );
}
}
$schema = Schema::get();
// For storing user-submitted flags on profiles
- $schema->ensureTable('registration_ip',
- array(new ColumnDef('user_id', 'integer', null,
- false, 'PRI'),
- new ColumnDef('ipaddress', 'varchar', 15, false, 'MUL'),
- new ColumnDef('created', 'timestamp', null, false, 'MUL')));
-
+ $schema->ensureTable('registration_ip', Registration_ip::schemaDef());
return true;
}
public $__table = 'registration_ip'; // table name
public $user_id; // int(4) primary_key not_null
public $ipaddress; // varchar(15)
- public $created; // timestamp
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * return table definition for DB_DataObject
- *
- * @return array array of column definitions
- */
- function table()
- {
- return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'ipaddress' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL);
- }
-
- /**
- * 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('user_id' => 'K');
- }
-
- /**
- * 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 $this->keys();
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * If a table has a single integer column as its primary key, DB_DataObject
- * assumes that the column is auto-incrementing and makes a sequence table
- * to do this incrementation. Since we don't need this for our class, we
- * overload this method and return the magic formula that DB_DataObject needs.
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
+ public static function schemaDef()
{
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id this registration relates to'),
+ 'ipaddress' => array('type' => 'varchar', 'length' => 45, 'description' => 'IP address, max 45+null in IPv6'),
+ '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('user_id'),
+ 'foreign keys' => array(
+ 'registration_ip_user_id_fkey' => array('user', array('user_id' => 'id')),
+ ),
+ 'indexes' => array(
+ 'registration_ip_ipaddress_idx' => array('ipaddress'),
+ 'registration_ip_created_idx' => array('created'),
+ ),
+ );
}
/**
$schema = Schema::get();
// For storing user-submitted flags on profiles
-
- $schema->ensureTable('user_greeting_count',
- array(
- 'fields' => array(
- 'user_id' => array('type' => 'int', 'not null' => true),
- 'greeting_count' => array('type' => 'int'),
- ),
- 'primary key' => array('user_id'),
- 'foreign keys' => array(
- // Not all databases will support foreign keys, but even
- // when not enforced it's helpful to include these definitions
- // as documentation.
- 'user_greeting_count_user_id_fkey' => array('user', array('user_id' => 'id')),
- ),
- )
- );
-
+ $schema->ensureTable('user_greeting_count', User_greeting_count::schemaDef());
return true;
}
public $__table = 'user_greeting_count'; // table name
public $user_id; // int(4) primary_key not_null
public $greeting_count; // int(4)
+ public $created; // datetime() not_null
+ public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
- /**
- * 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('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'greeting_count' => DB_DATAOBJECT_INT);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- 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. This key information is used to store and clear
- * cached data, so be sure to list any key that will be used for static
- * lookups.
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('user_id' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * If a table has a single integer column as its primary key, DB_DataObject
- * assumes that the column is auto-incrementing and makes a sequence table
- * to do this incrementation. Since we don't need this for our class, we
- * overload this method and return the magic formula that DB_DataObject needs.
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
+ public static function schemaDef()
{
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
+ 'greeting_count' => array('type' => 'int', 'not null' => true, 'description' => 'the greeting count'),
+ '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('user_id'),
+ 'foreign keys' => array(
+ 'user_greeting_count_user_id_fkey' => array('user', array('user_id' => 'id')),
+ ),
+ );
}
/**
{
$schema = Schema::get();
- $schema->ensureTable('sitemap_user_count',
- array(new ColumnDef('registration_date', 'date', null,
- true, 'PRI'),
- new ColumnDef('user_count', 'integer'),
- new ColumnDef('created', 'datetime',
- null, false),
- new ColumnDef('modified', 'timestamp')));
-
- $schema->ensureTable('sitemap_notice_count',
- array(new ColumnDef('notice_date', 'date', null,
- true, 'PRI'),
- new ColumnDef('notice_count', 'integer'),
- new ColumnDef('created', 'datetime',
- null, false),
- new ColumnDef('modified', 'timestamp')));
-
+ $schema->ensureTable('sitemap_user_count', Sitemap_user_count::schemaDef());
+ $schema->ensureTable('sitemap_notice_count', Sitemap_notice_count::schemaDef());
return true;
}
public $notice_date; // date primary_key not_null
public $notice_count; // int(4)
- 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_date' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_NOTNULL,
- 'notice_count' => DB_DATAOBJECT_INT,
- '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);
- }
-
- /**
- * 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('notice_date' => 'K');
- }
+ public $created; // datetime() not_null
+ public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
- /**
- * 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()
+ public static function schemaDef()
{
- return $this->keys();
+ return array(
+ 'fields' => array(
+ 'notice_date' => array('type' => 'date', 'not null' => true, 'description' => 'record date'),
+ 'notice_count' => array('type' => 'int', 'not null' => true, 'description' => 'the notice count'),
+ '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_date'),
+ );
}
static function getAll()
public $registration_date; // date primary_key not_null
public $user_count; // int(4)
- 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('registration_date' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_NOTNULL,
- 'user_count' => DB_DATAOBJECT_INT,
- '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);
- }
-
- /**
- * 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('registration_date' => 'K');
- }
-
- function sequenceKey()
- {
- return array(false, false, false);
- }
-
- /**
- * 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 $this->keys();
+ public $created; // datetime() not_null
+ public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
+
+ public static function schemaDef()
+ {
+ return array(
+ 'fields' => array(
+ 'registration_date' => array('type' => 'date', 'not null' => true, 'description' => 'record date'),
+ 'user_count' => array('type' => 'int', 'not null' => true, 'description' => 'the user count of the recorded date'),
+ '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('registration_date'),
+ );
}
static function getAll()
{
public $__table = 'notice_to_status'; // table name
public $notice_id; // int(4) primary_key not_null
- public $status_id; // int(4)
- public $created; // datetime
+ public $status_id; // bigint not_null
+ public $created; // datetime() not_null
+ public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
- /**
- * 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,
- 'status_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- 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. This key information is used to store and clear
- * cached data, so be sure to list any key that will be used for static
- * lookups.
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('notice_id' => 'K', 'status_id' => 'U');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * If a table has a single integer column as its primary key, DB_DataObject
- * assumes that the column is auto-incrementing and makes a sequence table
- * to do this incrementation. Since we don't need this for our class, we
- * overload this method and return the magic formula that DB_DataObject needs.
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
+ public static function schemaDef()
{
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'local notice id'),
+ 'status_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'twitter status id'),
+ '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'),
+ 'unique keys' => array(
+ 'status_id_key' => array('status_id'),
+ ),
+ 'foreign keys' => array(
+ 'notice_to_status_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
+ ),
+ );
}
/**
// For saving the last-synched status of various timelines
// home_timeline, messages (in), messages (out), ...
-
- $schema->ensureTable('twitter_synch_status',
- array(new ColumnDef('foreign_id', 'bigint', null,
- false, 'PRI'),
- new ColumnDef('timeline', 'varchar', 255,
- false, 'PRI'),
- new ColumnDef('last_id', 'bigint', null, // XXX: check for PostgreSQL
- false),
- new ColumnDef('created', 'datetime', null,
- false),
- new ColumnDef('modified', 'datetime', null,
- false)));
+ $schema->ensureTable('twitter_synch_status', Twitter_sync_status::schemaDef());
// For storing user-submitted flags on profiles
-
- $schema->ensureTable('notice_to_status',
- array(new ColumnDef('notice_id', 'integer', null,
- false, 'PRI'),
- new ColumnDef('status_id', 'bigint', null, // XXX: check for PostgreSQL
- false, 'UNI'),
- new ColumnDef('created', 'datetime', null,
- false)));
+ $schema->ensureTable('notice_to_status', Notice_to_status::schemaDef());
return true;
}
class Twitter_synch_status extends Managed_DataObject
{
public $__table = 'twitter_synch_status'; // table name
- public $foreign_id; // int(4) primary_key not_null
+ public $foreign_id; // bigint primary_key not_null
public $timeline; // varchar(255) primary_key not_null
public $last_id; // bigint not_null
- public $created; // datetime not_null
- public $modified; // datetime not_null
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- /**
- * 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()
+ public static function schemaDef()
{
- return array('foreign_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'timeline' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
- 'last_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- '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
- );
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * DB_DataObject needs to know about keys that the table has, since it
- * won't appear in StatusNet's own keys list. In most cases, this will
- * simply reference your keyTypes() function.
- *
- * @return array list of key field names
- */
- 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. This key information is used to store and clear
- * cached data, so be sure to list any key that will be used for static
- * lookups.
- *
- * @return array associative array of key definitions, field name to type:
- * 'K' for primary key: for compound keys, add an entry for each component;
- * 'U' for unique keys: compound keys are not well supported here.
- */
- function keyTypes()
- {
- return array('foreign_id' => 'K',
- 'timeline' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * If a table has a single integer column as its primary key, DB_DataObject
- * assumes that the column is auto-incrementing and makes a sequence table
- * to do this incrementation. Since we don't need this for our class, we
- * overload this method and return the magic formula that DB_DataObject needs.
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
- {
- return array(false, false, false);
+ return array(
+ 'fields' => array(
+ 'foreign_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'Foreign message ID'),
+ 'timeline' => array('type' => 'varchar', 'length' => 255, 'description' => 'timeline name'),
+ 'last_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'last id fetched'),
+ '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('foreign_id', 'timeline'),
+ );
}
static function getLastId($foreign_id, $timeline)
$schema = Schema::get();
// For storing user-submitted flags on profiles
-
- $schema->ensureTable('user_flag_profile',
- array(new ColumnDef('profile_id', 'integer', null,
- false, 'PRI'),
- new ColumnDef('user_id', 'integer', null,
- false, 'PRI'),
- new ColumnDef('created', 'datetime', null,
- false, 'MUL'),
- new ColumnDef('cleared', 'datetime', null,
- true, 'MUL')));
-
+ $schema->ensureTable('user_flag_profile', User_flag_profile::schemaDef());
return true;
}
/* the code below is auto generated do not remove the above tag */
public $__table = 'user_flag_profile'; // table name
- public $profile_id; // int(4) primary_key not_null
- public $user_id; // int(4) primary_key not_null
- public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
- public $cleared; // datetime not_null default_0000-00-00%2000%3A00%3A00
+ public $profile_id; // int(11) primary_key not_null
+ public $user_id; // int(11) primary_key not_null
+ public $cleared; // datetime default_0000-00-00%2000%3A00%3A00
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- /**
- * return table definition for DB_DataObject
- *
- * @return array array of column definitions
- */
- function table()
+ public static function schemaDef()
{
return array(
- 'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
- 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
- 'cleared' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
- );
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * @return array of key names
- */
- function keys()
- {
- return array_keys($this->keyTypes());
- }
-
- /**
- * return key definitions for DB_DataObject
- *
- * @return array map of key definitions
- */
- function keyTypes()
- {
- return array('profile_id' => 'K', 'user_id' => 'K');
- }
-
- /**
- * Magic formula for non-autoincrementing integer primary keys
- *
- * If a table has a single integer column as its primary key, DB_DataObject
- * assumes that the column is auto-incrementing and makes a sequence table
- * to do this incrementation. Since we don't need this for our class, we
- * overload this method and return the magic formula that DB_DataObject needs.
- *
- * @return array magic three-false array that stops auto-incrementing.
- */
- function sequenceKey()
- {
- return array(false, false, false);
+ 'fields' => array(
+ 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile id flagged'),
+ 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id of the actor'),
+ 'cleared' => array('type' => 'datetime', 'description' => 'when flag was removed'),
+ '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('profile_id', 'user_id'),
+ 'indexes' => array(
+ 'user_flag_profile_cleared_idx' => array('cleared'),
+ 'user_flag_profile_created_idx' => array('created'),
+ ),
+ );
}
/**