diff --git a/classes/Avatar.php b/classes/Avatar.php index bdf3739bbf..d871d360b6 100644 --- a/classes/Avatar.php +++ b/classes/Avatar.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Avatar extends Memcached_DataObject +class Avatar extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -32,6 +32,32 @@ class Avatar extends Memcached_DataObject return Memcached_DataObject::pivotGet('Avatar', $keyCol, $keyVals, $otherCols); } + public static function schemaDef() + { + return array( + 'fields' => array( + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), + 'original' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'uploaded by user or generated?'), + 'width' => array('type' => 'int', 'not null' => true, 'description' => 'image width'), + 'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'), + 'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'), + 'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'local filename, if local'), + 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'avatar location'), + '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', 'width', 'height'), + 'unique keys' => array( + 'avatar_url_key' => array('url'), + ), + 'foreign keys' => array( + 'avatar_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + ), + 'indexes' => array( + 'avatar_profile_id_idx' => array('profile_id'), + ), + ); + } // We clean up the file, too function delete() diff --git a/classes/Config.php b/classes/Config.php index e14730438e..ba0db588ca 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -27,7 +27,7 @@ if (!defined('STATUSNET')) { require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Config extends Memcached_DataObject +class Config extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,6 +43,18 @@ class Config extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'section' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration section'), + 'setting' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration setting'), + 'value' => array('type' => 'varchar', 'length' => 255, 'description' => 'configuration value'), + ), + 'primary key' => array('section', 'setting'), + ); + } + const settingsKey = 'config:settings'; static function loadSettings() diff --git a/classes/Confirm_address.php b/classes/Confirm_address.php index 4b9bec64c6..056df836fc 100644 --- a/classes/Confirm_address.php +++ b/classes/Confirm_address.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Confirm_address extends Memcached_DataObject +class Confirm_address extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -26,8 +26,25 @@ class Confirm_address extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function sequenceKey() - { return array(false, false); } + public static function schemaDef() + { + return array( + 'fields' => array( + 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'), + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who requested confirmation'), + 'address' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'address (email, xmpp, SMS, etc.)'), + 'address_extra' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'carrier ID, for SMS'), + 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'), + 'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'), + 'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('code'), + 'foreign keys' => array( + 'confirm_address_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); + } static function getAddress($address, $addressType) { diff --git a/classes/Consumer.php b/classes/Consumer.php index c1090b85a3..1d32d853bd 100644 --- a/classes/Consumer.php +++ b/classes/Consumer.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Consumer extends Memcached_DataObject +class Consumer extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -23,6 +23,22 @@ class Consumer extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'description' => 'OAuth consumer record', + 'fields' => array( + 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'unique identifier, root URL'), + 'consumer_secret' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'secret value'), + 'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'), + + '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('consumer_key'), + ); + } + static function generateNew() { $cons = new Consumer(); diff --git a/classes/Conversation.php b/classes/Conversation.php index e029c20ba0..4bad474c73 100755 --- a/classes/Conversation.php +++ b/classes/Conversation.php @@ -29,7 +29,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; -class Conversation extends Memcached_DataObject +class Conversation extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -46,6 +46,22 @@ class Conversation extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'uri' => array('type' => 'varchar', 'length' => 225, 'description' => 'URI of the conversation'), + '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( + 'conversation_uri_key' => array('uri'), + ), + ); + } + /** * Factory method for creating a new conversation * diff --git a/classes/Deleted_notice.php b/classes/Deleted_notice.php index 64dc85da65..d3f9c0bf7c 100644 --- a/classes/Deleted_notice.php +++ b/classes/Deleted_notice.php @@ -26,7 +26,7 @@ if (!defined('STATUSNET')) { */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Deleted_notice extends Memcached_DataObject +class Deleted_notice extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,4 +43,24 @@ class Deleted_notice extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity of notice'), + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'author of the notice'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice record was created'), + 'deleted' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice record was created'), + ), + 'primary key' => array('id'), + 'unique keys' => array( + 'deleted_notice_uri_key' => array('uri'), + ), + 'indexes' => array( + 'deleted_notice_profile_id_idx' => array('profile_id'), + ), + ); + } } diff --git a/classes/Fave.php b/classes/Fave.php index d954117292..467465ba05 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Fave extends Memcached_DataObject +class Fave extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,6 +22,31 @@ class Fave extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the favorite'), + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who likes this notice'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('notice_id', 'user_id'), + 'unique keys' => array( + 'fave_uri_key' => array('uri'), + ), + 'foreign keys' => array( + 'fave_notice_id_fkey' => array('notice', array('notice_id' => 'id')), + 'fave_user_id_fkey' => array('profile', array('user_id' => 'id')), // note: formerly referenced notice.id, but we can now record remote users' favorites + ), + 'indexes' => array( + 'fave_notice_id_idx' => array('notice_id'), + 'fave_user_id_idx' => array('user_id', 'modified'), + 'fave_modified_idx' => array('modified'), + ), + ); + } + /** * Save a favorite record. * @fixme post-author notification should be moved here diff --git a/classes/File.php b/classes/File.php index 767a108087..f716a9d64c 100644 --- a/classes/File.php +++ b/classes/File.php @@ -29,7 +29,7 @@ require_once INSTALLDIR.'/classes/File_to_post.php'; /** * Table Definition for file */ -class File extends Memcached_DataObject +class File extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -51,6 +51,28 @@ class File extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true), + 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'destination URL after following redirections'), + 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'), + 'size' => array('type' => 'int', 'description' => 'size of resource when available'), + 'title' => array('type' => 'varchar', 'length' => 255, 'description' => 'title of resource when available'), + 'date' => array('type' => 'int', 'description' => 'date of resource according to http query'), + 'protected' => array('type' => 'int', 'description' => 'true when URL is private (needs login)'), + 'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'if a local file, name of the file'), + + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('id'), + 'unique keys' => array( + 'file_url_key' => array('url'), + ), + ); + } + function isProtected($url) { return 'http://www.facebook.com/login.php' === $url; } diff --git a/classes/File_oembed.php b/classes/File_oembed.php index b7bf3a5dae..ae46e61bd4 100644 --- a/classes/File_oembed.php +++ b/classes/File_oembed.php @@ -26,7 +26,7 @@ require_once INSTALLDIR.'/classes/File_redirection.php'; * Table Definition for file_oembed */ -class File_oembed extends Memcached_DataObject +class File_oembed extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -53,9 +53,30 @@ class File_oembed extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function sequenceKey() + public static function schemaDef() { - return array(false, false, false); + return array( + 'fields' => array( + 'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'oEmbed for that URL/file'), + 'version' => array('type' => 'varchar', 'length' => 20, 'description' => 'oEmbed spec. version'), + 'type' => array('type' => 'varchar', 'length' => 20, 'description' => 'oEmbed type: photo, video, link, rich'), + 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'), + 'provider' => array('type' => 'varchar', 'length' => 50, 'description' => 'name of this oEmbed provider'), + 'provider_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of this oEmbed provider'), + 'width' => array('type' => 'int', 'description' => 'width of oEmbed resource when available'), + 'height' => array('type' => 'int', 'description' => 'height of oEmbed resource when available'), + 'html' => array('type' => 'text', 'description' => 'html representation of this oEmbed resource when applicable'), + 'title' => array('type' => 'varchar', 'length' => 255, 'description' => 'title of oEmbed resource when available'), + 'author_name' => array('type' => 'varchar', 'length' => 50, 'description' => 'author name for this oEmbed resource'), + 'author_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'author URL for this oEmbed resource'), + 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL for this oEmbed resource when applicable (photo, link)'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('file_id'), + 'foreign keys' => array( + 'file_oembed_file_id_fkey' => array('file', array('file_id' => 'id')), + ), + ); } function _getOembed($url) { diff --git a/classes/File_redirection.php b/classes/File_redirection.php index 74e89db5f2..130d9e7d74 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -27,7 +27,7 @@ require_once INSTALLDIR.'/classes/File_oembed.php'; * Table Definition for file_redirection */ -class File_redirection extends Memcached_DataObject +class File_redirection extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -45,6 +45,23 @@ class File_redirection extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'url' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'short URL (or any other kind of redirect) for file (id)'), + 'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'), + 'redirections' => array('type' => 'int', 'description' => 'redirect count'), + 'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('url'), + 'foreign keys' => array( + 'file_redirection_file_id_fkey' => array('file' => array('file_id' => 'id')), + ), + ); + } + static function _commonHttp($url, $redirs) { $request = new HTTPClient($url); $request->setConfig(array( diff --git a/classes/File_thumbnail.php b/classes/File_thumbnail.php index 17bac7f08c..064b454e2d 100644 --- a/classes/File_thumbnail.php +++ b/classes/File_thumbnail.php @@ -25,7 +25,7 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; * Table Definition for file_thumbnail */ -class File_thumbnail extends Memcached_DataObject +class File_thumbnail extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,9 +43,24 @@ class File_thumbnail extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function sequenceKey() + public static function schemaDef() { - return array(false, false, false); + return array( + 'fields' => array( + 'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'thumbnail for what URL/file'), + 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of thumbnail'), + 'width' => array('type' => 'int', 'description' => 'width of thumbnail'), + 'height' => array('type' => 'int', 'description' => 'height of thumbnail'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('file_id'), + 'foreign keys' => array( + 'file_thumbnail_file_id_fkey' => array('file', array('file_id' => 'id')), + ), + 'unique keys' => array( + 'file_thumbnail_url_key' => array('url'), + ), + ); } /** diff --git a/classes/File_to_post.php b/classes/File_to_post.php index bcb6771f4f..1a887a7c18 100644 --- a/classes/File_to_post.php +++ b/classes/File_to_post.php @@ -25,7 +25,7 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; * Table Definition for file_to_post */ -class File_to_post extends Memcached_DataObject +class File_to_post extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -41,6 +41,25 @@ class File_to_post extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'), + 'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('file_id', 'post_id'), + 'foreign keys' => array( + 'file_to_post_file_id_fkey' => array('file', array('file_id' => 'id')), + 'file_to_post_post_id_fkey' => array('notice', array('post_id' => 'id')), + ), + 'indexes' => array( + 'post_id_idx' => array('post_id'), + ), + ); + } + function processNew($file_id, $notice_id) { static $seen = array(); if (empty($seen[$notice_id]) || !in_array($file_id, $seen[$notice_id])) { diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php index 57a10dcedb..e3f0cf1ee6 100644 --- a/classes/Foreign_link.php +++ b/classes/Foreign_link.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Foreign_link extends Memcached_DataObject +class Foreign_link extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -29,6 +29,34 @@ class Foreign_link extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'link to user on this system, if exists'), + 'foreign_id' => array('type' => 'int', 'size' => 'big', 'unsigned' => true, 'not null' => true, 'description' => 'link to user on foreign service, if exists'), + 'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'), + 'credentials' => array('type' => 'varchar', 'length' => 255, 'description' => 'authc credentials, typically a password'), + 'noticesync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'notice synchronization, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies'), + 'friendsync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 2, 'description' => 'friend synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'), + 'profilesync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'), + 'last_noticesync' => array('type' => 'datetime', 'description' => 'last time notices were imported'), + 'last_friendsync' => array('type' => 'datetime', 'description' => 'last time friends were imported'), + '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_id', 'service'), + 'foreign keys' => array( + 'foreign_link_user_id_fkey' => array('user', array('user_id' => 'id')), + 'foreign_link_foreign_id_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')), + 'foreign_link_service_fkey' => array('foreign_service', array('service' => 'id')), + ), + 'indexes' => array( + 'foreign_user_user_id_idx' => array('user_id'), + ), + ); + } + static function getByUserID($user_id, $service) { if (empty($user_id) || empty($service)) { diff --git a/classes/Foreign_service.php b/classes/Foreign_service.php index dd74fd2ca6..8ba73521c1 100644 --- a/classes/Foreign_service.php +++ b/classes/Foreign_service.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Foreign_service extends Memcached_DataObject +class Foreign_service extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,4 +22,21 @@ class Foreign_service extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'int', 'not null' => true, 'description' => 'numeric key for service'), + 'name' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'), + 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description'), + '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( + 'foreign_service_name_key' => array('name'), + ), + ); + } } diff --git a/classes/Foreign_subscription.php b/classes/Foreign_subscription.php index ec2631238e..99bf3868b5 100644 --- a/classes/Foreign_subscription.php +++ b/classes/Foreign_subscription.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Foreign_subscription extends Memcached_DataObject +class Foreign_subscription extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -21,4 +21,27 @@ class Foreign_subscription extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + + 'fields' => array( + 'service' => array('type' => 'int', 'not null' => true, 'description' => 'service where relationship happens'), + 'subscriber' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscriber on foreign service'), + 'subscribed' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscribed user'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + ), + 'primary key' => array('service', 'subscriber', 'subscribed'), + 'foreign keys' => array( + 'foreign_subscription_service_fkey' => array('foreign_service', array('service' => 'id')), + 'foreign_subscription_subscriber_fkey' => array('foreign_user', array('subscriber' => 'id', 'service' => 'service')), + 'foreign_subscription_subscribed_fkey' => array('foreign_user', array('subscribed' => 'id', 'service' => 'service')), + ), + 'indexes' => array( + 'foreign_subscription_subscriber_idx' => array('service', 'subscriber'), + 'foreign_subscription_subscribed_idx' => array('service', 'subscribed'), + ), + ); + } } diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php index 82ca749a59..67d8651fa9 100644 --- a/classes/Foreign_user.php +++ b/classes/Foreign_user.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Foreign_user extends Memcached_DataObject +class Foreign_user extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -23,6 +23,27 @@ class Foreign_user extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'), + 'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'identifying URI'), + 'nickname' => array('type' => 'varchar', 'length' => 255, 'description' => 'nickname on foreign service'), + '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', 'service'), + 'foreign keys' => array( + 'foreign_user_service_fkey' => array('foreign_service', array('service' => 'id')), + ), + 'unique keys' => array( + 'foreign_user_uri_key' => array('uri'), + ), + ); + } + // XXX: This only returns a 1->1 single obj mapping. Change? Or make // a getForeignUsers() that returns more than one? --Zach static function getForeignUser($id, $service) { diff --git a/classes/Group_alias.php b/classes/Group_alias.php index c5a1895a11..fcf5405547 100644 --- a/classes/Group_alias.php +++ b/classes/Group_alias.php @@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Group_alias extends Memcached_DataObject +class Group_alias extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -38,4 +38,22 @@ class Group_alias extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + 'fields' => array( + 'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'), + 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'), + ), + 'primary key' => array('alias'), + 'foreign keys' => array( + 'group_alias_group_id_fkey' => array('user_group', array('group_id' => 'id')), + ), + 'indexes' => array( + 'group_alias_group_id_idx' => array('group_id'), + ), + ); + } } diff --git a/classes/Group_block.php b/classes/Group_block.php index 68feaef4de..dc439ba774 100644 --- a/classes/Group_block.php +++ b/classes/Group_block.php @@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Group_block extends Memcached_DataObject +class Group_block extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -40,6 +40,24 @@ class Group_block extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'), + 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'), + 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'), + ), + 'primary key' => array('group_id', 'blocked'), + 'foreign keys' => array( + 'group_block_group_id_fkey' => array('user_group', array('group_id' => 'id')), + 'group_block_blocked_fkey' => array('profile', array('blocked' => 'id')), + 'group_block_blocker_fkey' => array('user', array('blocker' => 'id')), + ), + ); + } + function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Group_block', $kv); diff --git a/classes/Group_inbox.php b/classes/Group_inbox.php index 8f5c65e594..0e01c20b46 100644 --- a/classes/Group_inbox.php +++ b/classes/Group_inbox.php @@ -3,7 +3,7 @@ /** * Table Definition for group_inbox */ -class Group_inbox extends Memcached_DataObject +class Group_inbox extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -20,6 +20,27 @@ class Group_inbox extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'description' => 'Many-many table listing notices posted to a given group, or which groups a given notice was posted to.', + 'fields' => array( + 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group receiving the message'), + 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created'), + ), + 'primary key' => array('group_id', 'notice_id'), + 'foreign keys' => array( + 'group_inbox_group_id_fkey' => array('user_group', array('group_id' => 'id')), + 'group_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id')), + ), + 'indexes' => array( + 'group_inbox_created_idx' => array('created'), + 'group_inbox_notice_id_idx' => array('notice_id'), + ), + ); + } + function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Group_inbox', $kv); diff --git a/classes/Group_member.php b/classes/Group_member.php index a553af3475..2ad6589a3c 100644 --- a/classes/Group_member.php +++ b/classes/Group_member.php @@ -3,7 +3,7 @@ * Table Definition for group_member */ -class Group_member extends Memcached_DataObject +class Group_member extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,6 +22,33 @@ class Group_member extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), + 'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), + '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', 'profile_id'), + 'unique keys' => array( + 'group_member_uri_key' => array('uri'), + ), + 'foreign keys' => array( + 'group_member_group_id_fkey' => array('user_group', array('group_id' => 'id')), + 'group_member_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + ), + 'indexes' => array( + // @fixme probably we want a (profile_id, created) index here? + 'group_member_profile_id_idx' => array('profile_id'), + 'group_member_created_idx' => array('created'), + ), + ); + } + function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Group_member', $kv); diff --git a/classes/Inbox.php b/classes/Inbox.php index 336bba048c..c618ff7aca 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -29,7 +29,7 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Inbox extends Memcached_DataObject +class Inbox extends Managed_DataObject { const BOXCAR = 128; const MAX_NOTICES = 1024; @@ -47,9 +47,18 @@ class Inbox extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - 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 receiving the notice'), + 'notice_ids' => array('type' => 'blob', 'description' => 'packed list of notice ids'), + ), + 'primary key' => array('user_id'), + 'foreign keys' => array( + 'inbox_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); } /** diff --git a/classes/Invitation.php b/classes/Invitation.php index 27ff400883..ae34a31023 100644 --- a/classes/Invitation.php +++ b/classes/Invitation.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Invitation extends Memcached_DataObject +class Invitation extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -30,4 +30,29 @@ class Invitation extends Memcached_DataObject $this->registered_user_id = $user->id; return $this->update($orig); } + + public static function schemaDef() + { + return array( + + 'fields' => array( + 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'random code for an invitation'), + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'), + 'address' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'invitation sent to'), + 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + 'registered_user_id' => array('type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'), + ), + 'primary key' => array('code'), + 'foreign keys' => array( + 'invitation_user_id_fkey' => array('user', array('user_id' => 'id')), + 'invitation_registered_user_id_fkey' => array('user', array('registered_user_id' => 'id')), + ), + 'indexes' => array( + 'invitation_address_idx' => array('address', 'address_type'), + 'invitation_user_id_idx' => array('user_id'), + 'invitation_registered_user_id_idx' => array('registered_user_id'), + ), + ); + } } diff --git a/classes/Local_group.php b/classes/Local_group.php index ccd0125cf4..44d8957838 100644 --- a/classes/Local_group.php +++ b/classes/Local_group.php @@ -3,7 +3,7 @@ * Table Definition for local_group */ -class Local_group extends Memcached_DataObject +class Local_group extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -20,9 +20,25 @@ class Local_group extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function sequenceKey() + public static function schemaDef() { - return array(false, false, false); + return array( + 'description' => 'Record for a user group on the local site, with some additional info not in user_group', + 'fields' => array( + 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'), + 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'), + + '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( + 'local_group_group_id_fkey' => array('user_group', array('group_id' => 'id')), + ), + 'unique keys' => array( + 'local_group_nickname_key' => array('nickname'), + ), + ); } function setNickname($nickname) diff --git a/classes/Location_namespace.php b/classes/Location_namespace.php index 5ab95d9ef2..7e12447a41 100644 --- a/classes/Location_namespace.php +++ b/classes/Location_namespace.php @@ -25,7 +25,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Location_namespace extends Memcached_DataObject +class Location_namespace extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,4 +43,17 @@ class Location_namespace extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'), + 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description of the namespace'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the record was created'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('id'), + ); + } } diff --git a/classes/Login_token.php b/classes/Login_token.php index 7a9388c947..7049c7c7fe 100644 --- a/classes/Login_token.php +++ b/classes/Login_token.php @@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Login_token extends Memcached_DataObject +class Login_token extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -40,21 +40,24 @@ class Login_token extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - const TIMEOUT = 120; // seconds after which to timeout the token - - /* - DB_DataObject calculates the sequence key(s) by taking the first key returned by the keys() function. - In this case, the keys() function returns user_id as the first key. user_id is not a sequence, but - DB_DataObject's sequenceKey() will incorrectly think it is. Then, since the sequenceKey() is a numeric - type, but is not set to autoincrement in the database, DB_DataObject will create a _seq table and - manage the sequence itself. This is not the correct behavior for the user_id in this class. - So we override that incorrect behavior, and simply say there is no sequence key. - */ - function sequenceKey() + public static function schemaDef() { - return array(false,false); + return array( + 'fields' => array( + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'), + 'token' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'token useable for logging in'), + '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( + 'login_token_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); } + const TIMEOUT = 120; // seconds after which to timeout the token + function makeNew($user) { $login_token = Login_token::staticGet('user_id', $user->id); diff --git a/classes/Message.php b/classes/Message.php index 484d1f724c..e04b4f47e3 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Message extends Memcached_DataObject +class Message extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -27,6 +27,39 @@ class Message extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier'), + 'from_profile' => array('type' => 'int', 'not null' => true, 'description' => 'who the message is from'), + 'to_profile' => array('type' => 'int', 'not null' => true, 'description' => 'who the message is to'), + 'content' => array('type' => 'text', 'description' => 'message content'), + 'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'), + 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'), + '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'), + 'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'), + ), + 'primary key' => array('id'), + 'unique keys' => array( + 'message_uri_key' => array('uri'), + ), + 'foreign keys' => array( + 'message_from_profile_fkey' => array('profile', array('from_profile' => 'id')), + 'message_to_profile_fkey' => array('profile', array('to_profile' => 'id')), + ), + 'indexes' => array( + // @fixme these are really terrible indexes, since you can only sort on one of them at a time. + // looks like we really need a (to_profile, created) for inbox and a (from_profile, created) for outbox + 'message_from_idx' => array('from_profile'), + 'message_to_idx' => array('to_profile'), + 'message_created_idx' => array('created'), + ), + ); + } + function getFrom() { return Profile::staticGet('id', $this->from_profile); diff --git a/classes/Nonce.php b/classes/Nonce.php index 93191bd409..0cd9967a08 100644 --- a/classes/Nonce.php +++ b/classes/Nonce.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Nonce extends Memcached_DataObject +class Nonce extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -36,4 +36,21 @@ class Nonce extends Memcached_DataObject { return array('consumer_key,token' => 'token:consumer_key,token'); } + + public static function schemaDef() + { + return array( + 'description' => 'OAuth nonce record', + 'fields' => array( + 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'unique identifier, root URL'), + 'tok' => array('type' => 'char', 'length' => 32, 'description' => 'buggy old value, ignored'), + 'nonce' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'nonce'), + 'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'), + + '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('consumer_key', 'ts', 'nonce'), + ); + } } diff --git a/classes/Notice.php b/classes/Notice.php index 0305baea34..e029880f8d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -49,7 +49,7 @@ define('NOTICE_CACHE_WINDOW', CachingNoticeStream::CACHE_WINDOW); define('MAX_BOXCARS', 128); -class Notice extends Memcached_DataObject +class Notice extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -85,6 +85,55 @@ class Notice extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), + 'content' => array('type' => 'text', 'description' => 'update content'), + 'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'), + 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'), + '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'), + 'reply_to' => array('type' => 'int', 'description' => 'notice replied to (usually a guess)'), + 'is_local' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'notice was generated by a user'), + 'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'), + 'conversation' => array('type' => 'int', 'description' => 'id of root notice in this conversation'), + 'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'), + 'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'), + 'location_id' => array('type' => 'int', 'description' => 'location id if possible'), + 'location_ns' => array('type' => 'int', 'description' => 'namespace for location'), + 'repeat_of' => array('type' => 'int', 'description' => 'notice this is a repeat of'), + 'object_type' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams object type', 'default' => 'http://activitystrea.ms/schema/1.0/note'), + 'scope' => array('type' => 'int', + 'default' => '1', + 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers'), + ), + 'primary key' => array('id'), + 'unique keys' => array( + 'notice_uri_key' => array('uri'), + ), + 'foreign keys' => array( + 'notice_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + 'notice_reply_to_fkey' => array('notice', array('reply_to' => 'id')), + 'notice_conversation_fkey' => array('conversation', array('conversation' => 'id')), # note... used to refer to notice.id + 'notice_repeat_of_fkey' => array('notice', array('repeat_of' => 'id')), # @fixme: what about repeats of deleted notices? + ), + 'indexes' => array( + 'notice_profile_id_idx' => array('profile_id', 'created', 'id'), + 'notice_conversation_idx' => array('conversation'), + 'notice_created_idx' => array('created'), + 'notice_replyto_idx' => array('reply_to'), + 'notice_repeatof_idx' => array('repeat_of'), + ), + 'fulltext indexes' => array( + 'content' => array('content'), + ) + ); + } + function multiGet($kc, $kvs, $skipNulls=true) { return Memcached_DataObject::multiGet('Notice', $kc, $kvs, $skipNulls); diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index 47ed6b22db..dcaf2f33b1 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -31,7 +31,7 @@ define('NOTICE_INBOX_GC_MAX', 12800); define('NOTICE_INBOX_LIMIT', 1000); define('NOTICE_INBOX_SOFT_LIMIT', 1000); -class Notice_inbox extends Memcached_DataObject +class Notice_inbox extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -49,6 +49,27 @@ class Notice_inbox extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'description' => 'Obsolete; old entries here are converted to packed entries in the inbox table since 0.9', + 'fields' => array( + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user receiving the message'), + 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created'), + 'source' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'reason it is in the inbox, 1=subscription'), + ), + 'primary key' => array('user_id', 'notice_id'), + 'foreign keys' => array( + 'notice_inbox_user_id_fkey' => array('user', array('user_id' => 'id')), + 'notice_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id')), + ), + 'indexes' => array( + 'notice_inbox_notice_id_idx' => array('notice_id'), + ), + ); + } + function stream($user_id, $offset, $limit, $since_id, $max_id, $own=false) { throw new Exception('Notice_inbox no longer used; use Inbox'); diff --git a/classes/Notice_source.php b/classes/Notice_source.php index 43893ebe18..a6649f5fba 100644 --- a/classes/Notice_source.php +++ b/classes/Notice_source.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Notice_source extends Memcached_DataObject +class Notice_source extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,4 +22,19 @@ class Notice_source extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + 'fields' => array( + 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'source code'), + 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'name of the source'), + 'url' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'url to link to'), + 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'date this record was created'), + '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('code'), + ); + } } diff --git a/classes/Notice_tag.php b/classes/Notice_tag.php index 809403a9bd..77c89dc8ce 100644 --- a/classes/Notice_tag.php +++ b/classes/Notice_tag.php @@ -19,7 +19,7 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Notice_tag extends Memcached_DataObject +class Notice_tag extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -36,6 +36,26 @@ class Notice_tag extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'description' => 'Hash tags', + 'fields' => array( + 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'), + 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice tagged'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + ), + 'primary key' => array('tag', 'notice_id'), + 'foreign keys' => array( + 'notice_tag_notice_id_fkey' => array('notice', array('notice_id' => 'id')), + ), + 'indexes' => array( + 'notice_tag_created_idx' => array('created'), + 'notice_tag_notice_id_idx' => array('notice_id'), + ), + ); + } + static function getStream($tag, $offset=0, $limit=20, $sinceId=0, $maxId=0) { $stream = new TagNoticeStream($tag); diff --git a/classes/Oauth_application.php b/classes/Oauth_application.php index f1d4fb7a6f..15faffe2fb 100644 --- a/classes/Oauth_application.php +++ b/classes/Oauth_application.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Oauth_application extends Memcached_DataObject +class Oauth_application extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -159,4 +159,35 @@ class Oauth_application extends Memcached_DataObject $oauser->application_id = $this->id; $oauser->delete(); } + + public static function schemaDef() + { + return array( + 'description' => 'OAuth application registration record', + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'owner' => array('type' => 'int', 'not null' => true, 'description' => 'owner of the application'), + 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'application consumer key'), + 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'name of the application'), + 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description of the application'), + 'icon' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'application icon'), + 'source_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'application homepage - used for source link'), + 'organization' => array('type' => 'varchar', 'length' => 255, 'description' => 'name of the organization running the application'), + 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'homepage for the organization'), + 'callback_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'url to redirect to after authentication'), + 'type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'type of app, 1 = browser, 2 = desktop'), + 'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'default access type, bit 1 = read, bit 2 = write'), + '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( + 'oauth_application_name_key' => array('name'), // in the long run, we should perhaps not force these unique, and use another source id + ), + 'foreign keys' => array( + 'oauth_application_owner_fkey' => array('profile', array('owner' => 'id')), // Are remote users allowed to create oauth application records? + 'oauth_application_consumer_key_fkey' => array('consumer', array('consumer_key' => 'consumer_key')), + ), + ); + } } diff --git a/classes/Oauth_application_user.php b/classes/Oauth_application_user.php index 834e38d2be..4d25672465 100644 --- a/classes/Oauth_application_user.php +++ b/classes/Oauth_application_user.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Oauth_application_user extends Memcached_DataObject +class Oauth_application_user extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -24,6 +24,25 @@ class Oauth_application_user extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'user of the application'), + 'application_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the application'), + 'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'access type, bit 1 = read, bit 2 = write'), + 'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'request or access token'), + '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', 'application_id'), + 'foreign keys' => array( + 'oauth_application_user_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + 'oauth_application_user_application_id_fkey' => array('oauth_application', array('application_id' => 'id')), + ), + ); + } + static function getByUserAndToken($user, $token) { if (empty($user) || empty($token)) { diff --git a/classes/Oauth_token_association.php b/classes/Oauth_token_association.php index 06c9fee1c3..17327d4b01 100644 --- a/classes/Oauth_token_association.php +++ b/classes/Oauth_token_association.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; -class Oauth_token_association extends Memcached_DataObject +class Oauth_token_association extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ diff --git a/classes/Profile.php b/classes/Profile.php index d5008d9fb8..bcbb406ae0 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -24,7 +24,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile extends Memcached_DataObject +class Profile extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -49,6 +49,36 @@ class Profile extends Memcached_DataObject return Memcached_DataObject::staticGet('Profile',$k,$v); } + public static function schemaDef() + { + return array( + 'description' => 'local and remote users have profiles', + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username'), + 'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name'), + 'profileurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL, cached so we dont regenerate'), + 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'identifying URL'), + 'bio' => array('type' => 'text', 'description' => 'descriptive biography'), + 'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'physical location'), + 'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'), + 'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'), + 'location_id' => array('type' => 'int', 'description' => 'location id if possible'), + 'location_ns' => array('type' => 'int', 'description' => 'namespace for location'), + + '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( + 'profile_nickname_idx' => array('nickname'), + ), + 'fulltext indexes' => array( + 'nickname' => array('nickname', 'fullname', 'location', 'bio', 'homepage') + ), + ); + } + function multiGet($keyCol, $keyVals, $skipNulls=true) { return parent::multiGet('Profile', $keyCol, $keyVals, $skipNulls); diff --git a/classes/Profile_block.php b/classes/Profile_block.php index 2d87edaa0a..8506283462 100644 --- a/classes/Profile_block.php +++ b/classes/Profile_block.php @@ -25,7 +25,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile_block extends Memcached_DataObject +class Profile_block extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -42,6 +42,22 @@ class Profile_block extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), + 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'), + ), + 'foreign keys' => array( + 'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')), + 'profile_block_blocked_fkey' => array('profile', array('blocked' => 'id')), + ), + 'primary key' => array('blocker', 'blocked'), + ); + } + function get($blocker, $blocked) { return Memcached_DataObject::pkeyGet('Profile_block', diff --git a/classes/Profile_list.php b/classes/Profile_list.php index 2395a369f3..50aa71f55d 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -30,7 +30,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile_list extends Memcached_DataObject +class Profile_list extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -54,6 +54,41 @@ class Profile_list extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'), + 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'people tag'), + 'description' => array('type' => 'text', 'description' => 'description of the people tag'), + 'private' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this tag private'), + + 'created' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'), + + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), + 'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page to link to'), + 'tagged_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of people tagged with this tag by this user'), + 'subscriber_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of subscribers to this tag'), + ), + 'primary key' => array('tagger', 'tag'), + 'unique keys' => array( + 'profile_list_id_key' => array('id') + ), + 'foreign keys' => array( + 'profile_list_tagger_fkey' => array('profile', array('tagger' => 'id')), + ), + 'indexes' => array( + 'profile_list_modified_idx' => array('modified'), + 'profile_list_tag_idx' => array('tag'), + 'profile_list_tagger_tag_idx' => array('tagger', 'tag'), + 'profile_list_tagged_count_idx' => array('tagged_count'), + 'profile_list_subscriber_count_idx' => array('subscriber_count'), + ), + ); + } + /** * return a profile_list record, given its tag and tagger. * diff --git a/classes/Profile_role.php b/classes/Profile_role.php index e7aa1f0f06..d89992b842 100644 --- a/classes/Profile_role.php +++ b/classes/Profile_role.php @@ -27,7 +27,7 @@ if (!defined('STATUSNET')) { require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile_role extends Memcached_DataObject +class Profile_role extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,6 +43,21 @@ class Profile_role extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'account having the role'), + 'role' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'string representing the role'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the role was granted'), + ), + 'primary key' => array('profile_id', 'role'), + 'foreign keys' => array( + 'profile_role_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + ), + ); + } + function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Profile_role', $kv); diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index 9e475e83ec..d9b094182f 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile_tag extends Memcached_DataObject +class Profile_tag extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,6 +22,30 @@ class Profile_tag extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + + 'fields' => array( + 'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'), + 'tagged' => array('type' => 'int', 'not null' => true, 'description' => 'profile tagged'), + 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'), + ), + 'primary key' => array('tagger', 'tagged', 'tag'), + 'foreign keys' => array( + 'profile_tag_tagger_fkey' => array('profile', array('tagger' => 'id')), + 'profile_tag_tagged_fkey' => array('profile', array('tagged' => 'id')), + 'profile_tag_tag_fkey' => array('profile_list', array('tag' => 'tag')), + ), + 'indexes' => array( + 'profile_tag_modified_idx' => array('modified'), + 'profile_tag_tagger_tag_idx' => array('tagger', 'tag'), + 'profile_tag_tagged_idx' => array('tagged'), + ), + ); + } + function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Profile_tag', $kv); } diff --git a/classes/Profile_tag_subscription.php b/classes/Profile_tag_subscription.php index 031405f531..ce4a57e870 100644 --- a/classes/Profile_tag_subscription.php +++ b/classes/Profile_tag_subscription.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile_tag_subscription extends Memcached_DataObject +class Profile_tag_subscription extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,6 +22,29 @@ class Profile_tag_subscription extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'), + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), + + '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_tag_id', 'profile_id'), + 'foreign keys' => array( + 'profile_tag_subscription_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')), + 'profile_tag_subscription_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + ), + 'indexes' => array( + // @fixme probably we want a (profile_id, created) index here? + 'profile_tag_subscription_profile_id_idx' => array('profile_id'), + 'profile_tag_subscription_created_idx' => array('created'), + ), + ); + } + function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Profile_tag_subscription', $kv); diff --git a/classes/Queue_item.php b/classes/Queue_item.php index d17e512b96..e34a89d2e3 100644 --- a/classes/Queue_item.php +++ b/classes/Queue_item.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Queue_item extends Memcached_DataObject +class Queue_item extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,6 +22,23 @@ class Queue_item extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'frame' => array('type' => 'blob', 'not null' => true, 'description' => 'data: object reference or opaque string'), + 'transport' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'queue for what? "email", "xmpp", "sms", "irc", ...'), // @fixme 8 chars is too short; bump up. + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + 'claimed' => array('type' => 'datetime', 'description' => 'date this item was claimed'), + ), + 'primary key' => array('id'), + 'indexes' => array( + 'queue_item_created_idx' => array('created'), + ), + ); + } + /** * @param mixed $transports name of a single queue or array of queues to pull from * If not specified, checks all queues in the system. diff --git a/classes/Related_group.php b/classes/Related_group.php index c00ad9c44e..67d6ce3fc7 100644 --- a/classes/Related_group.php +++ b/classes/Related_group.php @@ -3,7 +3,7 @@ * Table Definition for related_group */ -class Related_group extends Memcached_DataObject +class Related_group extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -18,4 +18,22 @@ class Related_group extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + // @fixme description for related_group? + 'fields' => array( + 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), + 'related_group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), + + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + ), + 'primary key' => array('group_id', 'related_group_id'), + 'foreign keys' => array( + 'related_group_group_id_fkey' => array('user_group', array('group_id' => 'id')), + 'related_group_related_group_id_fkey' => array('user_group', array('related_group_id' => 'id')), + ), + ); + } } diff --git a/classes/Remember_me.php b/classes/Remember_me.php index 3df7a99831..6523ad8174 100644 --- a/classes/Remember_me.php +++ b/classes/Remember_me.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Remember_me extends Memcached_DataObject +class Remember_me extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -23,8 +23,18 @@ class Remember_me extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function sequenceKey() + public static function schemaDef() { - return array(false, false); - } + return array( + 'fields' => array( + 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'), + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who is logged in'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('code'), + 'foreign keys' => array( + 'remember_me_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); + } } diff --git a/classes/Remote_profile.php b/classes/Remote_profile.php index 1672e9f956..d59f97ada7 100644 --- a/classes/Remote_profile.php +++ b/classes/Remote_profile.php @@ -24,7 +24,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Remote_profile extends Memcached_DataObject +class Remote_profile extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -54,4 +54,26 @@ class Remote_profile extends Memcached_DataObject throw new Exception(_("Missing profile.")); } } + + public static function schemaDef() + { + return array( + 'description' => 'remote people (OMB)', + 'fields' => array( + 'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), + 'postnoticeurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL we use for posting notices'), + 'updateprofileurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL we use for updates to this profile'), + '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( + 'remote_profile_uri_key' => array('uri'), + ), + 'foreign keys' => array( + 'remote_profile_id_fkey' => array('profile', array('id' => 'id')), + ), + ); + } } diff --git a/classes/Reply.php b/classes/Reply.php index acda0fecb4..3cc4b942ca 100644 --- a/classes/Reply.php +++ b/classes/Reply.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Reply extends Memcached_DataObject +class Reply extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,6 +22,28 @@ class Reply extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'), + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile replied to'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + 'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'), + ), + 'primary key' => array('notice_id', 'profile_id'), + 'foreign keys' => array( + 'reply_notice_id_fkey' => array('notice', array('notice_id' => 'id')), + 'reply_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + ), + 'indexes' => array( + 'reply_notice_id_idx' => array('notice_id'), + 'reply_profile_id_idx' => array('profile_id'), + 'reply_replied_id_idx' => array('replied_id'), + ), + ); + } + function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Reply',$kv); diff --git a/classes/Schema_version.php b/classes/Schema_version.php index 6b464c6d1d..4a3f939e93 100644 --- a/classes/Schema_version.php +++ b/classes/Schema_version.php @@ -3,7 +3,7 @@ * Table Definition for schema_version */ -class Schema_version extends Memcached_DataObject +class Schema_version extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -19,4 +19,17 @@ class Schema_version extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + public static function schemaDef() + { + return array( + 'description' => 'To avoid checking database structure all the time, we store a checksum of the expected schema info for each table here. If it has not changed since the last time we checked the table, we can leave it as is.', + 'fields' => array( + 'table_name' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Table name'), + 'checksum' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Checksum of schema array; a mismatch indicates we should check the table more thoroughly.'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('table_name'), + ); + } } diff --git a/classes/Session.php b/classes/Session.php index 166b89815a..1a924b7964 100644 --- a/classes/Session.php +++ b/classes/Session.php @@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Session extends Memcached_DataObject +class Session extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -40,6 +40,22 @@ class Session extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'), + 'session_data' => array('type' => 'text', 'description' => 'session data'), + '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( + 'session_modified_idx' => array('modified'), + ), + ); + } + static function logdeb($msg) { if (common_config('sessions', 'debug')) { diff --git a/classes/Sms_carrier.php b/classes/Sms_carrier.php index 500cb4f043..08d83f08f2 100644 --- a/classes/Sms_carrier.php +++ b/classes/Sms_carrier.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Sms_carrier extends Memcached_DataObject +class Sms_carrier extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -27,4 +27,21 @@ class Sms_carrier extends Memcached_DataObject { return sprintf($this->email_pattern, $sms); } + + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'), + 'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'), + 'email_pattern' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'), + '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( + 'sms_carrier_name_key' => array('name'), + ), + ); + } } diff --git a/classes/Subscription.php b/classes/Subscription.php index e0c5b5ab0e..f40239989c 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -24,7 +24,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Subscription extends Memcached_DataObject +class Subscription extends Managed_DataObject { const CACHE_WINDOW = 201; const FORCE = true; @@ -43,6 +43,32 @@ class Subscription extends Memcached_DataObject public $created; // datetime() not_null public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP + public static function schemaDef() + { + return array( + 'fields' => array( + 'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'profile listening'), + 'subscribed' => array('type' => 'int', 'not null' => true, 'description' => 'profile being listened to'), + 'jabber' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'deliver jabber messages'), + 'sms' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'deliver sms messages'), + 'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'authorization token'), + 'secret' => array('type' => 'varchar', 'length' => 255, 'description' => 'token secret'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier'), + '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('subscriber', 'subscribed'), + 'unique keys' => array( + 'subscription_uri_key' => array('uri'), + ), + 'indexes' => array( + 'subscription_subscriber_idx' => array('subscriber', 'created'), + 'subscription_subscribed_idx' => array('subscribed', 'created'), + 'subscription_token_idx' => array('token'), + ), + ); + } + /* Static get */ function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Subscription',$k,$v); } diff --git a/classes/Token.php b/classes/Token.php index a129d1fd11..8a6b46bbbb 100644 --- a/classes/Token.php +++ b/classes/Token.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Token extends Memcached_DataObject +class Token extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -26,4 +26,26 @@ class Token extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'description' => 'OAuth token record', + 'fields' => array( + 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'unique identifier, root URL'), + 'tok' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'identifying value'), + 'secret' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'secret value'), + 'type' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'request or access'), + 'state' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'for requests, 0 = initial, 1 = authorized, 2 = used'), + 'verifier' => array('type' => 'varchar', 'length' => 255, 'description' => 'verifier string for OAuth 1.0a'), + 'verified_callback' => array('type' => 'varchar', 'length' => 255, 'description' => 'verified callback URL for OAuth 1.0a'), + + '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('consumer_key', 'tok'), + 'foreign keys' => array( + 'token_consumer_key_fkey' => array('consumer', array('consumer_key'=> 'consumer_key')), + ), + ); + } } diff --git a/classes/User.php b/classes/User.php index d15c2c0ae6..93340f021d 100644 --- a/classes/User.php +++ b/classes/User.php @@ -28,7 +28,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; require_once 'Validate.php'; -class User extends Memcached_DataObject +class User extends Managed_DataObject { const SUBSCRIBE_POLICY_OPEN = 0; const SUBSCRIBE_POLICY_MODERATE = 1; @@ -71,6 +71,58 @@ class User extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'description' => 'local users', + 'fields' => array( + 'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), + 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname or username, duped in profile'), + 'password' => array('type' => 'varchar', 'length' => 255, 'description' => 'salted password, can be null for OpenID users'), + 'email' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for password recovery etc.'), + 'incomingemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for post-by-email'), + 'emailnotifysub' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of subscriptions'), + 'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of favorites'), + 'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'), + 'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'), + 'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'), + 'emailmicroid' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'whether to publish email microid'), + 'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'), + 'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'), + 'emailpost' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Post by email'), + 'sms' => array('type' => 'varchar', 'length' => 64, 'description' => 'sms phone number'), + 'carrier' => array('type' => 'int', 'description' => 'foreign key to sms_carrier'), + 'smsnotify' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS'), + 'smsreplies' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS on replies'), + 'smsemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'built from sms and carrier'), + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), + 'autosubscribe' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'automatically subscribe to users who subscribe to us'), + 'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'), + 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'), + 'inboxed' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'has an inbox been created for this user?'), + 'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'), + + '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( + 'user_nickname_key' => array('nickname'), + 'user_email_key' => array('email'), + 'user_incomingemail_key' => array('incomingemail'), + 'user_sms_key' => array('sms'), + 'user_uri_key' => array('uri'), + ), + 'foreign keys' => array( + 'user_id_fkey' => array('profile', array('id' => 'id')), + 'user_carrier_fkey' => array('sms_carrier', array('carrier' => 'id')), + ), + 'indexes' => array( + 'user_smsemail_idx' => array('smsemail'), + ), + ); + } + protected $_profile = -1; /** diff --git a/classes/User_group.php b/classes/User_group.php index 38cc5603db..8d08efb5ff 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -3,7 +3,7 @@ * Table Definition for user_group */ -class User_group extends Memcached_DataObject +class User_group extends Managed_DataObject { const JOIN_POLICY_OPEN = 0; const JOIN_POLICY_MODERATE = 1; @@ -42,6 +42,41 @@ class User_group extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + public static function schemaDef() + { + return array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + + 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname for addressing'), + 'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name'), + 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL, cached so we dont regenerate'), + 'description' => array('type' => 'text', 'description' => 'group description'), + 'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'related physical location, if any'), + + 'original_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'original size logo'), + 'homepage_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'homepage (profile) size logo'), + 'stream_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'stream-sized logo'), + 'mini_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'mini logo'), + + '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'), + + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), + 'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page for group info to link to'), + 'join_policy' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=open; 1=requires admin approval'), + 'force_scope' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=never,1=sometimes,-1=always'), + ), + 'primary key' => array('id'), + 'unique keys' => array( + 'user_group_uri_key' => array('uri'), + ), + 'indexes' => array( + 'user_group_nickname_idx' => array('nickname'), + ), + ); + } + function defaultLogo($size) { static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile', diff --git a/classes/User_im_prefs.php b/classes/User_im_prefs.php index 75be8969e0..cc9dea608d 100644 --- a/classes/User_im_prefs.php +++ b/classes/User_im_prefs.php @@ -29,7 +29,7 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_im_prefs extends Memcached_DataObject +class User_im_prefs extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -56,17 +56,28 @@ class User_im_prefs extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - /* - DB_DataObject calculates the sequence key(s) by taking the first key returned by the keys() function. - In this case, the keys() function returns user_id as the first key. user_id is not a sequence, but - DB_DataObject's sequenceKey() will incorrectly think it is. Then, since the sequenceKey() is a numeric - type, but is not set to autoincrement in the database, DB_DataObject will create a _seq table and - manage the sequence itself. This is not the correct behavior for the user_id in this class. - So we override that incorrect behavior, and simply say there is no sequence key. - */ - function sequenceKey() + public static function schemaDef() { - return array(false,false); + return array( + 'fields' => array( + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'), + 'screenname' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'screenname on this service'), + 'transport' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'), + 'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'), + 'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'), + 'microid' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'Publish a MicroID'), + 'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed 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('user_id', 'transport'), + 'unique keys' => array( + 'transport_screenname_key' => array('transport', 'screenname'), + ), + 'foreign keys' => array( + 'user_im_prefs_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); } /** diff --git a/classes/User_location_prefs.php b/classes/User_location_prefs.php index bd6029f97c..060ef41e83 100644 --- a/classes/User_location_prefs.php +++ b/classes/User_location_prefs.php @@ -29,7 +29,7 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_location_prefs extends Memcached_DataObject +class User_location_prefs extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -46,8 +46,19 @@ class User_location_prefs extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - 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 who has the preference'), + 'share_location' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Whether to share location data'), + '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_location_prefs_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); } } diff --git a/classes/User_urlshortener_prefs.php b/classes/User_urlshortener_prefs.php index e0f85af012..f71adc9736 100755 --- a/classes/User_urlshortener_prefs.php +++ b/classes/User_urlshortener_prefs.php @@ -21,7 +21,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -class User_urlshortener_prefs extends Memcached_DataObject +class User_urlshortener_prefs extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -40,9 +40,23 @@ class User_urlshortener_prefs extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - 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'), + 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'), + 'maxurllength' => array('type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, null = never'), + 'maxnoticelength' => array('type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, null = never'), + + '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_urlshortener_prefs_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); } static function maxUrlLength($user) diff --git a/classes/User_username.php b/classes/User_username.php index ae7785cc9f..652e7bd141 100644 --- a/classes/User_username.php +++ b/classes/User_username.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_username extends Memcached_DataObject +class User_username extends Managed_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ diff --git a/classes/statusnet.ini b/classes/statusnet.ini deleted file mode 100644 index c5c126a133..0000000000 --- a/classes/statusnet.ini +++ /dev/null @@ -1,720 +0,0 @@ -[avatar] -profile_id = 129 -original = 17 -width = 129 -height = 129 -mediatype = 130 -filename = 2 -url = 2 -created = 142 -modified = 384 - -[avatar__keys] -profile_id = K -width = K -height = K -url = U - -[config] -section = 130 -setting = 130 -value = 2 - -[config__keys] -section = K -setting = K - -[confirm_address] -code = 130 -user_id = 129 -address = 130 -address_extra = 130 -address_type = 130 -claimed = 14 -sent = 14 -modified = 384 - -[confirm_address__keys] -code = K - -[consumer] -consumer_key = 130 -consumer_secret = 130 -seed = 130 -created = 142 -modified = 384 - -[consumer__keys] -consumer_key = K - -[conversation] -id = 129 -uri = 2 -created = 142 -modified = 384 - -[conversation__keys] -id = N -uri = U - -[deleted_notice] -id = 129 -profile_id = 129 -uri = 2 -created = 142 -deleted = 142 - -[deleted_notice__keys] -id = K -uri = U - -[design] -id = 129 -backgroundcolor = 1 -contentcolor = 1 -sidebarcolor = 1 -textcolor = 1 -linkcolor = 1 -backgroundimage = 2 -disposition = 17 - -[design__keys] -id = N - -[fave] -notice_id = 129 -user_id = 129 -modified = 384 - -[fave__keys] -notice_id = K -user_id = K - -[file] -id = 129 -url = 2 -mimetype = 2 -size = 1 -title = 2 -date = 1 -protected = 1 -filename = 2 -modified = 384 - -[file__keys] -id = N -url = U - -[file_oembed] -file_id = 129 -version = 2 -type = 2 -mimetype = 2 -provider = 2 -provider_url = 2 -width = 1 -height = 1 -html = 34 -title = 2 -author_name = 2 -author_url = 2 -url = 2 -modified = 384 - -[file_oembed__keys] -file_id = K - -[file_redirection] -url = 130 -file_id = 1 -redirections = 1 -httpcode = 1 -modified = 384 - -[file_redirection__keys] -url = K - -[file_thumbnail] -file_id = 129 -url = 2 -width = 1 -height = 1 -modified = 384 - -[file_thumbnail__keys] -file_id = K -url = U - -[file_to_post] -file_id = 129 -post_id = 129 -modified = 384 - -[file_to_post__keys] -file_id = K -post_id = K - -[foreign_link] -user_id = 129 -foreign_id = 129 -service = 129 -credentials = 2 -noticesync = 145 -friendsync = 145 -profilesync = 145 -last_noticesync = 14 -last_friendsync = 14 -created = 142 -modified = 384 - -[foreign_link__keys] -user_id = K -foreign_id = K -service = K - -[foreign_service] -id = 129 -name = 130 -description = 2 -created = 142 -modified = 384 - -[foreign_service__keys] -id = K -name = U - -[foreign_subscription] -service = 129 -subscriber = 129 -subscribed = 129 -created = 142 - -[foreign_subscription__keys] -service = K -subscriber = K -subscribed = K - -[foreign_user] -id = 129 -service = 129 -uri = 130 -nickname = 2 -created = 142 -modified = 384 - -[foreign_user__keys] -id = K -service = K -uri = U - -[group_alias] -alias = 130 -group_id = 129 -modified = 384 - -[group_alias__keys] -alias = K - -[group_block] -group_id = 129 -blocked = 129 -blocker = 129 -modified = 384 - -[group_block__keys] -group_id = K -blocked = K - -[group_inbox] -group_id = 129 -notice_id = 129 -created = 142 - -[group_inbox__keys] -group_id = K -notice_id = K - -[group_member] -group_id = 129 -profile_id = 129 -is_admin = 17 -created = 142 -modified = 384 - -[group_member__keys] -group_id = K -profile_id = K - -[inbox] -user_id = 129 -notice_ids = 66 - -[inbox__keys] -user_id = K - -[invitation] -code = 130 -user_id = 129 -address = 130 -address_type = 130 -created = 142 -registered_user_id = 1 - -[invitation__keys] -code = K - -[local_group] -group_id = 129 -nickname = 2 -created = 142 -modified = 384 - -[local_group__keys] -group_id = K -nickname = U - -[location_namespace] -id = 129 -description = 2 -created = 142 -modified = 384 - -[location_namespace__keys] -id = K - -[login_token] -user_id = 129 -token = 130 -created = 142 -modified = 384 - -[login_token__keys] -user_id = K - -[message] -id = 129 -uri = 2 -from_profile = 129 -to_profile = 129 -content = 34 -rendered = 34 -url = 2 -created = 142 -modified = 384 -source = 2 - -[message__keys] -id = N - -[nonce] -consumer_key = 130 -tok = 2 -nonce = 130 -ts = 142 -created = 142 -modified = 384 - -[nonce__keys] -consumer_key = K -nonce = K -ts = K - -[notice] -id = 129 -profile_id = 129 -uri = 2 -content = 34 -rendered = 34 -url = 2 -created = 142 -modified = 384 -reply_to = 1 -is_local = 17 -source = 2 -conversation = 1 -lat = 1 -lon = 1 -location_id = 1 -location_ns = 1 -repeat_of = 1 -object_type = 2 -scope = 1 - -[notice__keys] -id = N - -[notice_inbox] -user_id = 129 -notice_id = 129 -created = 142 -source = 17 - -[notice_inbox__keys] -user_id = K -notice_id = K - -[notice_source] -code = 130 -name = 130 -url = 130 -created = 142 -modified = 384 - -[notice_source__keys] -code = K - -[notice_tag] -tag = 130 -notice_id = 129 -created = 142 - -[notice_tag__keys] -tag = K -notice_id = K - -[oauth_application] -id = 129 -owner = 129 -consumer_key = 130 -name = 130 -description = 2 -icon = 130 -source_url = 2 -organization = 2 -homepage = 2 -callback_url = 2 -type = 17 -access_type = 17 -created = 142 -modified = 384 - -[oauth_application__keys] -id = N -name = U - -[oauth_application_user] -profile_id = 129 -application_id = 129 -access_type = 17 -token = 2 -created = 142 -modified = 384 - -[oauth_application_user__keys] -profile_id = K -application_id = K - -[oauth_token_association] -profile_id = 129 -application_id = 129 -token = 130 -created = 142 -modified = 384 - -[oauth_token_association__keys] -profile_id = K -application_id = K -token = K - -[profile] -id = 129 -nickname = 130 -fullname = 2 -profileurl = 2 -homepage = 2 -bio = 34 -location = 2 -lat = 1 -lon = 1 -location_id = 1 -location_ns = 1 -created = 142 -modified = 384 - -[profile__keys] -id = N - -[profile_block] -blocker = 129 -blocked = 129 -modified = 384 - -[profile_block__keys] -blocker = K -blocked = K - -[profile_role] -profile_id = 129 -role = 130 -created = 142 - -[profile_role__keys] -profile_id = K -role = K - -[profile_tag] -tagger = 129 -tagged = 129 -tag = 130 -modified = 384 - -[profile_tag__keys] -tagger = K -tagged = K -tag = K - -[profile_list] -id = 129 -tagger = 129 -tag = 130 -description = 34 -private = 17 -created = 142 -modified = 384 -uri = 130 -mainpage = 130 -tagged_count = 129 -subscriber_count = 129 - -[profile_list__keys] -id = U -tagger = K -tag = K - -[profile_tag_subscription] -profile_tag_id = 129 -profile_id = 129 -created = 142 -modified = 384 - -[profile_tag_subscription__keys] -profile_tag_id = K -profile_id = K - -[queue_item] -id = 129 -frame = 194 -transport = 130 -created = 142 -claimed = 14 - -[queue_item__keys] -id = N - -[related_group] -group_id = 129 -related_group_id = 129 -created = 142 - -[related_group__keys] -group_id = K -related_group_id = K - -[remember_me] -code = 130 -user_id = 129 -modified = 384 - -[remember_me__keys] -code = K - -[remote_profile] -id = 129 -uri = 2 -postnoticeurl = 2 -updateprofileurl = 2 -created = 142 -modified = 384 - -[remote_profile__keys] -id = K -uri = U - -[reply] -notice_id = 129 -profile_id = 129 -modified = 142 -;modified = 384 ; skipping the mysql_timestamp mode so we can override its setting -replied_id = 1 - -[reply__keys] -notice_id = K -profile_id = K - -[schema_version] -table_name = 130 -checksum = 130 -modified = 384 - -[schema_version__keys] -table_name = K - -[session] -id = 130 -session_data = 34 -created = 142 -modified = 384 - -[session__keys] -id = K - -[sms_carrier] -id = 129 -name = 2 -email_pattern = 130 -created = 142 -modified = 384 - -[sms_carrier__keys] -id = K -name = U - -[subscription] -subscriber = 129 -subscribed = 129 -jabber = 17 -sms = 17 -token = 2 -secret = 2 -created = 142 -modified = 384 - -[subscription__keys] -subscriber = K -subscribed = K - -[token] -consumer_key = 130 -tok = 130 -secret = 130 -type = 145 -state = 17 -verifier = 2 -verified_callback = 2 -created = 142 -modified = 384 - -[token__keys] -consumer_key = K -tok = K - -[user] -id = 129 -nickname = 2 -password = 2 -email = 2 -incomingemail = 2 -emailnotifysub = 17 -emailnotifyfav = 17 -emailnotifynudge = 17 -emailnotifymsg = 17 -emailnotifyattn = 17 -emailmicroid = 17 -language = 2 -timezone = 2 -emailpost = 17 -sms = 2 -carrier = 1 -smsnotify = 17 -smsreplies = 17 -smsemail = 2 -uri = 2 -autosubscribe = 17 -subscribe_policy = 17 -urlshorteningservice = 2 -inboxed = 17 -design_id = 1 -viewdesigns = 17 -private_stream = 17 -created = 142 -modified = 384 - -[user__keys] -id = K -nickname = U -email = U -incomingemail = U -sms = U -uri = U - -[user_group] -id = 129 -nickname = 2 -fullname = 2 -homepage = 2 -description = 34 -location = 2 -original_logo = 2 -homepage_logo = 2 -stream_logo = 2 -mini_logo = 2 -design_id = 1 -created = 142 -modified = 384 -uri = 2 -mainpage = 2 -join_policy = 1 -force_scope = 1 - -[user_group__keys] -id = N - -[user_openid] -canonical = 130 -display = 130 -user_id = 129 -created = 142 -modified = 384 - -[user_openid__keys] -canonical = K -display = U - -[user_openid_trustroot] -trustroot = 130 -user_id = 129 -created = 142 -modified = 384 - -[user_openid__keys] -trustroot = K -user_id = K - -[user_location_prefs] -user_id = 129 -share_location = 17 -created = 142 -modified = 384 - -[user_location_prefs__keys] -user_id = K - -[user_im_prefs] -user_id = 129 -screenname = 130 -transport = 130 -notify = 17 -replies = 17 -microid = 17 -updatefrompresence = 17 -created = 142 -modified = 384 - -[user_im_prefs__keys] -user_id = K -transport = K -; There's another unique index on (transport, screenname) -; but we have no way to represent a compound index other than -; the primary key in here. To ensure proper cache purging, -; we need to tweak the class. - -[user_urlshortener_prefs] -user_id = 129 -urlshorteningservice = 2 -maxurllength = 129 -maxnoticelength = 129 -created = 142 -modified = 384 - -[user_urlshortener_prefs__keys] -user_id = K diff --git a/classes/statusnet.links.ini b/classes/statusnet.links.ini deleted file mode 100644 index 17a8c40085..0000000000 --- a/classes/statusnet.links.ini +++ /dev/null @@ -1,74 +0,0 @@ -[avatar] -profile_id = profile:id - -[user] -id = profile:id -carrier = sms_carrier:id - -[remote_profile] -id = profile:id - -[notice] -profile_id = profile:id -reply_to = notice:id -profile_id = profile_tag:tagged - -[reply] -notice_id = notice:id -profile_id = profile:id - -[token] -consumer_key = consumer:consumer_key - -; Compatibility hack for PHP 5.3 -; This entry has been moved to the class definition, as commas are no longer -; considered valid in keys, causing parse_ini_file() to reject the whole file. -;[nonce] -;consumer_key,token = token:consumer_key,token - -[confirm_address] -user_id = user:id - -[remember_me] -user_id = user:id - -[queue_item] -notice_id = notice:id - -[subscription] -subscriber = profile:id -subscribed = profile:id - -[fave] -notice_id = notice:id -user_id = user:id - -[file_oembed] -file_id = file:id - -[file_redirection] -file_id = file:id - -[file_thumbnail] -file_id = file:id - -[file_to_post] -file_id = file:id -post_id = notice:id - -[profile_list] -tagger = profile:id - -[profile_tag] -tagger = profile:id -tagged = profile:id -; in class definition: -;tag,tagger = profile_list:tag,tagger - -[profile_list] -tagger = profile:id - -[profile_tag_subscription] -profile_tag_id = profile_list:id -profile_id = profile:id - diff --git a/db/core.php b/db/core.php index cfecd23d47..c484c8c785 100644 --- a/db/core.php +++ b/db/core.php @@ -29,1077 +29,65 @@ * double-check what we've been doing on postgres? */ -$schema['profile'] = array( - 'description' => 'local and remote users have profiles', - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username'), - 'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name'), - 'profileurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL, cached so we dont regenerate'), - 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'identifying URL'), - 'bio' => array('type' => 'text', 'description' => 'descriptive biography'), - 'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'physical location'), - 'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'), - 'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'), - 'location_id' => array('type' => 'int', 'description' => 'location id if possible'), - 'location_ns' => array('type' => 'int', 'description' => 'namespace for location'), - - '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( - 'profile_nickname_idx' => array('nickname'), - ), - 'fulltext indexes' => array( - 'nickname' => array('nickname', 'fullname', 'location', 'bio', 'homepage') - ), +$classes = array('Profile', + 'Avatar', + 'Sms_carrier', + 'User', + 'Remote_profile', + 'Subscription', + 'Group_join_queue', + 'Subscription_queue', + 'Oauth_token_association', + 'Notice', + 'Notice_source', + 'Reply', + 'Fave', + 'Consumer', + 'Token', + 'Nonce', + 'Oauth_application', + 'Oauth_application_user', + 'Confirm_address', + 'Remember_me', + 'Queue_item', + 'Notice_tag', + 'Foreign_service', + 'Foreign_user', + 'Foreign_link', + 'Foreign_subscription', + 'Invitation', + 'Message', + // 'Notice_inbox', + 'Profile_tag', + 'Profile_list', + 'Profile_tag_subscription', + 'Profile_block', + 'User_group', + 'Related_group', + 'Group_inbox', + 'Group_member', + 'File', + 'File_oembed', + 'File_redirection', + 'File_thumbnail', + 'File_to_post', + 'Group_block', + 'Group_alias', + 'Session', + 'Deleted_notice', + 'Config', + 'Profile_role', + 'Location_namespace', + 'Login_token', + 'User_location_prefs', + 'Inbox', + 'User_im_prefs', + 'Conversation', + 'Local_group', + 'User_urlshortener_prefs', + 'Schema_version', ); -$schema['avatar'] = array( - 'fields' => array( - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), - 'original' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'uploaded by user or generated?'), - 'width' => array('type' => 'int', 'not null' => true, 'description' => 'image width'), - 'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'), - 'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'), - 'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'local filename, if local'), - 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'avatar location'), - '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', 'width', 'height'), - 'unique keys' => array( - 'avatar_url_key' => array('url'), - ), - 'foreign keys' => array( - 'avatar_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - ), - 'indexes' => array( - 'avatar_profile_id_idx' => array('profile_id'), - ), -); - -$schema['sms_carrier'] = array( - 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'), - 'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'), - 'email_pattern' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'), - '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( - 'sms_carrier_name_key' => array('name'), - ), -); - -$schema['user'] = array( - 'description' => 'local users', - 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), - 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname or username, duped in profile'), - 'password' => array('type' => 'varchar', 'length' => 255, 'description' => 'salted password, can be null for OpenID users'), - 'email' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for password recovery etc.'), - 'incomingemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for post-by-email'), - 'emailnotifysub' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of subscriptions'), - 'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of favorites'), - 'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'), - 'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'), - 'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'), - 'emailmicroid' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'whether to publish email microid'), - 'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'), - 'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'), - 'emailpost' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Post by email'), - 'sms' => array('type' => 'varchar', 'length' => 64, 'description' => 'sms phone number'), - 'carrier' => array('type' => 'int', 'description' => 'foreign key to sms_carrier'), - 'smsnotify' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS'), - 'smsreplies' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS on replies'), - 'smsemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'built from sms and carrier'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), - 'autosubscribe' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'automatically subscribe to users who subscribe to us'), - 'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'), - 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'), - 'inboxed' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'has an inbox been created for this user?'), - 'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'), - - '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( - 'user_nickname_key' => array('nickname'), - 'user_email_key' => array('email'), - 'user_incomingemail_key' => array('incomingemail'), - 'user_sms_key' => array('sms'), - 'user_uri_key' => array('uri'), - ), - 'foreign keys' => array( - 'user_id_fkey' => array('profile', array('id' => 'id')), - 'user_carrier_fkey' => array('sms_carrier', array('carrier' => 'id')), - ), - 'indexes' => array( - 'user_smsemail_idx' => array('smsemail'), - ), -); - -$schema['remote_profile'] = array( - 'description' => 'remote people (OMB)', - 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), - 'postnoticeurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL we use for posting notices'), - 'updateprofileurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL we use for updates to this profile'), - '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( - 'remote_profile_uri_key' => array('uri'), - ), - 'foreign keys' => array( - 'remote_profile_id_fkey' => array('profile', array('id' => 'id')), - ), -); - -$schema['subscription'] = array( - 'fields' => array( - 'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'profile listening'), - 'subscribed' => array('type' => 'int', 'not null' => true, 'description' => 'profile being listened to'), - 'jabber' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'deliver jabber messages'), - 'sms' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'deliver sms messages'), - 'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'authorization token'), - 'secret' => array('type' => 'varchar', 'length' => 255, 'description' => 'token secret'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier'), - '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('subscriber', 'subscribed'), - 'unique keys' => array( - 'subscription_uri_key' => array('uri'), - ), - 'indexes' => array( - 'subscription_subscriber_idx' => array('subscriber', 'created'), - 'subscription_subscribed_idx' => array('subscribed', 'created'), - 'subscription_token_idx' => array('token'), - ), -); - -$schema['notice'] = array( - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), - 'content' => array('type' => 'text', 'description' => 'update content'), - 'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'), - 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'), - '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'), - 'reply_to' => array('type' => 'int', 'description' => 'notice replied to (usually a guess)'), - 'is_local' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'notice was generated by a user'), - 'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'), - 'conversation' => array('type' => 'int', 'description' => 'id of root notice in this conversation'), - 'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'), - 'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'), - 'location_id' => array('type' => 'int', 'description' => 'location id if possible'), - 'location_ns' => array('type' => 'int', 'description' => 'namespace for location'), - 'repeat_of' => array('type' => 'int', 'description' => 'notice this is a repeat of'), - 'object_type' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams object type', 'default' => 'http://activitystrea.ms/schema/1.0/note'), - 'verb' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams verb', 'default' => 'http://activitystrea.ms/schema/1.0/post'), - 'scope' => array('type' => 'int', - 'default' => '1', - 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers'), - ), - 'primary key' => array('id'), - 'unique keys' => array( - 'notice_uri_key' => array('uri'), - ), - 'foreign keys' => array( - 'notice_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - 'notice_reply_to_fkey' => array('notice', array('reply_to' => 'id')), - 'notice_conversation_fkey' => array('conversation', array('conversation' => 'id')), # note... used to refer to notice.id - 'notice_repeat_of_fkey' => array('notice', array('repeat_of' => 'id')), # @fixme: what about repeats of deleted notices? - ), - 'indexes' => array( - 'notice_profile_id_idx' => array('profile_id', 'created', 'id'), - 'notice_conversation_idx' => array('conversation'), - 'notice_created_idx' => array('created'), - 'notice_replyto_idx' => array('reply_to'), - 'notice_repeatof_idx' => array('repeat_of'), - ), - 'fulltext indexes' => array( - 'content' => array('content'), - ) -); - -$schema['notice_source'] = array( - 'fields' => array( - 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'source code'), - 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'name of the source'), - 'url' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'url to link to'), - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'date this record was created'), - '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('code'), -); - -$schema['reply'] = array( - 'fields' => array( - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'), - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile replied to'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - 'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'), - ), - 'primary key' => array('notice_id', 'profile_id'), - 'foreign keys' => array( - 'reply_notice_id_fkey' => array('notice', array('notice_id' => 'id')), - 'reply_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - ), - 'indexes' => array( - 'reply_notice_id_idx' => array('notice_id'), - 'reply_profile_id_idx' => array('profile_id'), - 'reply_replied_id_idx' => array('replied_id'), - ), -); - -$schema['fave'] = array( - 'fields' => array( - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the favorite'), - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who likes this notice'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('notice_id', 'user_id'), - 'unique keys' => array( - 'fave_uri_key' => array('uri'), - ), - 'foreign keys' => array( - 'fave_notice_id_fkey' => array('notice', array('notice_id' => 'id')), - 'fave_user_id_fkey' => array('profile', array('user_id' => 'id')), // note: formerly referenced notice.id, but we can now record remote users' favorites - ), - 'indexes' => array( - 'fave_notice_id_idx' => array('notice_id'), - 'fave_user_id_idx' => array('user_id', 'modified'), - 'fave_modified_idx' => array('modified'), - ), -); - -/* tables for OAuth */ - -$schema['consumer'] = array( - 'description' => 'OAuth consumer record', - 'fields' => array( - 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'unique identifier, root URL'), - 'consumer_secret' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'secret value'), - 'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'), - - '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('consumer_key'), -); - -$schema['token'] = array( - 'description' => 'OAuth token record', - 'fields' => array( - 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'unique identifier, root URL'), - 'tok' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'identifying value'), - 'secret' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'secret value'), - 'type' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'request or access'), - 'state' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'for requests, 0 = initial, 1 = authorized, 2 = used'), - 'verifier' => array('type' => 'varchar', 'length' => 255, 'description' => 'verifier string for OAuth 1.0a'), - 'verified_callback' => array('type' => 'varchar', 'length' => 255, 'description' => 'verified callback URL for OAuth 1.0a'), - - '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('consumer_key', 'tok'), - 'foreign keys' => array( - 'token_consumer_key_fkey' => array('consumer', array('consumer_key'=> 'consumer_key')), - ), -); - -$schema['nonce'] = array( - 'description' => 'OAuth nonce record', - 'fields' => array( - 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'unique identifier, root URL'), - 'tok' => array('type' => 'char', 'length' => 32, 'description' => 'buggy old value, ignored'), - 'nonce' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'nonce'), - 'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'), - - '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('consumer_key', 'ts', 'nonce'), -); - -$schema['oauth_application'] = array( - 'description' => 'OAuth application registration record', - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'owner' => array('type' => 'int', 'not null' => true, 'description' => 'owner of the application'), - 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'application consumer key'), - 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'name of the application'), - 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description of the application'), - 'icon' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'application icon'), - 'source_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'application homepage - used for source link'), - 'organization' => array('type' => 'varchar', 'length' => 255, 'description' => 'name of the organization running the application'), - 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'homepage for the organization'), - 'callback_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'url to redirect to after authentication'), - 'type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'type of app, 1 = browser, 2 = desktop'), - 'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'default access type, bit 1 = read, bit 2 = write'), - '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( - 'oauth_application_name_key' => array('name'), // in the long run, we should perhaps not force these unique, and use another source id - ), - 'foreign keys' => array( - 'oauth_application_owner_fkey' => array('profile', array('owner' => 'id')), // Are remote users allowed to create oauth application records? - 'oauth_application_consumer_key_fkey' => array('consumer', array('consumer_key' => 'consumer_key')), - ), -); - -$schema['oauth_application_user'] = array( - 'fields' => array( - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'user of the application'), - 'application_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the application'), - 'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'access type, bit 1 = read, bit 2 = write'), - 'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'request or access token'), - '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', 'application_id'), - 'foreign keys' => array( - 'oauth_application_user_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - 'oauth_application_user_application_id_fkey' => array('oauth_application', array('application_id' => 'id')), - ), -); - -/* These are used by JanRain OpenID library */ - -$schema['oid_associations'] = array( - 'fields' => array( - 'server_url' => array('type' => 'blob', 'not null' => true), - 'handle' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), // character set latin1, - 'secret' => array('type' => 'blob'), - 'issued' => array('type' => 'int'), - 'lifetime' => array('type' => 'int'), - 'assoc_type' => array('type' => 'varchar', 'length' => 64), - ), - 'primary key' => array(array('server_url', 255), 'handle'), -); - -$schema['oid_nonces'] = array( - 'fields' => array( - 'server_url' => array('type' => 'varchar', 'length' => 2047), - 'timestamp' => array('type' => 'int'), - 'salt' => array('type' => 'char', 'length' => 40), - ), - 'unique keys' => array( - 'oid_nonces_server_url_timestamp_salt_key' => array(array('server_url', 255), 'timestamp', 'salt'), - ), -); - -$schema['confirm_address'] = array( - 'fields' => array( - 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'), - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who requested confirmation'), - 'address' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'address (email, xmpp, SMS, etc.)'), - 'address_extra' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'carrier ID, for SMS'), - 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'), - 'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'), - 'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('code'), - 'foreign keys' => array( - 'confirm_address_user_id_fkey' => array('user', array('user_id' => 'id')), - ), -); - -$schema['remember_me'] = array( - 'fields' => array( - 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'), - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who is logged in'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('code'), - 'foreign keys' => array( - 'remember_me_user_id_fkey' => array('user', array('user_id' => 'id')), - ), -); - -$schema['queue_item'] = array( - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'frame' => array('type' => 'blob', 'not null' => true, 'description' => 'data: object reference or opaque string'), - 'transport' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'queue for what? "email", "xmpp", "sms", "irc", ...'), // @fixme 8 chars is too short; bump up. - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), - 'claimed' => array('type' => 'datetime', 'description' => 'date this item was claimed'), - ), - 'primary key' => array('id'), - 'indexes' => array( - 'queue_item_created_idx' => array('created'), - ), -); - -$schema['notice_tag'] = array( - 'description' => 'Hash tags', - 'fields' => array( - 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'), - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice tagged'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), - ), - 'primary key' => array('tag', 'notice_id'), - 'foreign keys' => array( - 'notice_tag_notice_id_fkey' => array('notice', array('notice_id' => 'id')), - ), - 'indexes' => array( - 'notice_tag_created_idx' => array('created'), - 'notice_tag_notice_id_idx' => array('notice_id'), - ), -); - -/* Synching with foreign services */ - -$schema['foreign_service'] = array( - 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'numeric key for service'), - 'name' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'), - 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description'), - '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( - 'foreign_service_name_key' => array('name'), - ), -); - -$schema['foreign_user'] = array( - 'fields' => array( - 'id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'), - 'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'identifying URI'), - 'nickname' => array('type' => 'varchar', 'length' => 255, 'description' => 'nickname on foreign service'), - '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', 'service'), - 'foreign keys' => array( - 'foreign_user_service_fkey' => array('foreign_service', array('service' => 'id')), - ), - 'unique keys' => array( - 'foreign_user_uri_key' => array('uri'), - ), -); - -$schema['foreign_link'] = array( - 'fields' => array( - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'link to user on this system, if exists'), - 'foreign_id' => array('type' => 'int', 'size' => 'big', 'unsigned' => true, 'not null' => true, 'description' => 'link to user on foreign service, if exists'), - 'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'), - 'credentials' => array('type' => 'varchar', 'length' => 255, 'description' => 'authc credentials, typically a password'), - 'noticesync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'notice synchronization, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies'), - 'friendsync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 2, 'description' => 'friend synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'), - 'profilesync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'), - 'last_noticesync' => array('type' => 'datetime', 'description' => 'last time notices were imported'), - 'last_friendsync' => array('type' => 'datetime', 'description' => 'last time friends were imported'), - '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_id', 'service'), - 'foreign keys' => array( - 'foreign_link_user_id_fkey' => array('user', array('user_id' => 'id')), - 'foreign_link_foreign_id_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')), - 'foreign_link_service_fkey' => array('foreign_service', array('service' => 'id')), - ), - 'indexes' => array( - 'foreign_user_user_id_idx' => array('user_id'), - ), -); - -$schema['foreign_subscription'] = array( - 'fields' => array( - 'service' => array('type' => 'int', 'not null' => true, 'description' => 'service where relationship happens'), - 'subscriber' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscriber on foreign service'), - 'subscribed' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscribed user'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), - ), - 'primary key' => array('service', 'subscriber', 'subscribed'), - 'foreign keys' => array( - 'foreign_subscription_service_fkey' => array('foreign_service', array('service' => 'id')), - 'foreign_subscription_subscriber_fkey' => array('foreign_user', array('subscriber' => 'id', 'service' => 'service')), - 'foreign_subscription_subscribed_fkey' => array('foreign_user', array('subscribed' => 'id', 'service' => 'service')), - ), - 'indexes' => array( - 'foreign_subscription_subscriber_idx' => array('service', 'subscriber'), - 'foreign_subscription_subscribed_idx' => array('service', 'subscribed'), - ), -); - -$schema['invitation'] = array( - 'fields' => array( - 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'random code for an invitation'), - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'), - 'address' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'invitation sent to'), - 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), - 'registered_user_id' => array('type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'), - ), - 'primary key' => array('code'), - 'foreign keys' => array( - 'invitation_user_id_fkey' => array('user', array('user_id' => 'id')), - 'invitation_registered_user_id_fkey' => array('user', array('registered_user_id' => 'id')), - ), - 'indexes' => array( - 'invitation_address_idx' => array('address', 'address_type'), - 'invitation_user_id_idx' => array('user_id'), - 'invitation_registered_user_id_idx' => array('registered_user_id'), - ), -); - -$schema['message'] = array( - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier'), - 'from_profile' => array('type' => 'int', 'not null' => true, 'description' => 'who the message is from'), - 'to_profile' => array('type' => 'int', 'not null' => true, 'description' => 'who the message is to'), - 'content' => array('type' => 'text', 'description' => 'message content'), - 'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'), - 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'), - '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'), - 'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'), - ), - 'primary key' => array('id'), - 'unique keys' => array( - 'message_uri_key' => array('uri'), - ), - 'foreign keys' => array( - 'message_from_profile_fkey' => array('profile', array('from_profile' => 'id')), - 'message_to_profile_fkey' => array('profile', array('to_profile' => 'id')), - ), - 'indexes' => array( - // @fixme these are really terrible indexes, since you can only sort on one of them at a time. - // looks like we really need a (to_profile, created) for inbox and a (from_profile, created) for outbox - 'message_from_idx' => array('from_profile'), - 'message_to_idx' => array('to_profile'), - 'message_created_idx' => array('created'), - ), -); - -$schema['notice_inbox'] = array( - 'description' => 'Obsolete; old entries here are converted to packed entries in the inbox table since 0.9', - 'fields' => array( - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user receiving the message'), - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created'), - 'source' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'reason it is in the inbox, 1=subscription'), - ), - 'primary key' => array('user_id', 'notice_id'), - 'foreign keys' => array( - 'notice_inbox_user_id_fkey' => array('user', array('user_id' => 'id')), - 'notice_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id')), - ), - 'indexes' => array( - 'notice_inbox_notice_id_idx' => array('notice_id'), - ), -); - -$schema['profile_tag'] = array( - 'fields' => array( - 'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'), - 'tagged' => array('type' => 'int', 'not null' => true, 'description' => 'profile tagged'), - 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'), - ), - 'primary key' => array('tagger', 'tagged', 'tag'), - 'foreign keys' => array( - 'profile_tag_tagger_fkey' => array('profile', array('tagger' => 'id')), - 'profile_tag_tagged_fkey' => array('profile', array('tagged' => 'id')), - 'profile_tag_tag_fkey' => array('profile_list', array('tag' => 'tag')), - ), - 'indexes' => array( - 'profile_tag_modified_idx' => array('modified'), - 'profile_tag_tagger_tag_idx' => array('tagger', 'tag'), - 'profile_tag_tagged_idx' => array('tagged'), - ), -); - -$schema['profile_list'] = array( - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'), - 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'people tag'), - 'description' => array('type' => 'text', 'description' => 'description of the people tag'), - 'private' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this tag private'), - - 'created' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'), - - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), - 'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page to link to'), - 'tagged_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of people tagged with this tag by this user'), - 'subscriber_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of subscribers to this tag'), - ), - 'primary key' => array('tagger', 'tag'), - 'unique keys' => array( - 'profile_list_id_key' => array('id') - ), - 'foreign keys' => array( - 'profile_list_tagger_fkey' => array('profile', array('tagger' => 'id')), - ), - 'indexes' => array( - 'profile_list_modified_idx' => array('modified'), - 'profile_list_tag_idx' => array('tag'), - 'profile_list_tagger_tag_idx' => array('tagger', 'tag'), - 'profile_list_tagged_count_idx' => array('tagged_count'), - 'profile_list_subscriber_count_idx' => array('subscriber_count'), - ), -); - -$schema['profile_tag_inbox'] = array( - 'description' => 'Many-many table listing notices associated with people tags.', - 'fields' => array( - 'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'people tag receiving the message'), - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created'), - ), - 'primary key' => array('profile_tag_id', 'notice_id'), - 'foreign keys' => array( - 'profile_tag_inbox_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')), - 'profile_tag_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id')), - ), - 'indexes' => array( - 'profile_tag_inbox_created_idx' => array('created'), - 'profile_tag_inbox_profile_tag_id_idx' => array('profile_tag_id'), - ), -); - -$schema['profile_tag_subscription'] = array( - 'fields' => array( - 'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'), - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), - - '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_tag_id', 'profile_id'), - 'foreign keys' => array( - 'profile_tag_subscription_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')), - 'profile_tag_subscription_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - ), - 'indexes' => array( - // @fixme probably we want a (profile_id, created) index here? - 'profile_tag_subscription_profile_id_idx' => array('profile_id'), - 'profile_tag_subscription_created_idx' => array('created'), - ), -); - -$schema['profile_block'] = array( - 'fields' => array( - 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), - 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'), - ), - 'foreign keys' => array( - 'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')), - 'profile_block_blocked_fkey' => array('profile', array('blocked' => 'id')), - ), - 'primary key' => array('blocker', 'blocked'), -); - -$schema['user_group'] = array( - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - - 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname for addressing'), - 'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name'), - 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL, cached so we dont regenerate'), - 'description' => array('type' => 'text', 'description' => 'group description'), - 'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'related physical location, if any'), - - 'original_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'original size logo'), - 'homepage_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'homepage (profile) size logo'), - 'stream_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'stream-sized logo'), - 'mini_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'mini logo'), - - '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'), - - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), - 'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page for group info to link to'), - 'join_policy' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=open; 1=requires admin approval'), - 'force_scope' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=never,1=sometimes,-1=always'), - ), - 'primary key' => array('id'), - 'unique keys' => array( - 'user_group_uri_key' => array('uri'), - ), - 'indexes' => array( - 'user_group_nickname_idx' => array('nickname'), - ), -); - -$schema['group_member'] = array( - 'fields' => array( - 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), - 'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), - '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', 'profile_id'), - 'unique keys' => array( - 'group_member_uri_key' => array('uri'), - ), - 'foreign keys' => array( - 'group_member_group_id_fkey' => array('user_group', array('group_id' => 'id')), - 'group_member_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - ), - 'indexes' => array( - // @fixme probably we want a (profile_id, created) index here? - 'group_member_profile_id_idx' => array('profile_id'), - 'group_member_created_idx' => array('created'), - ), -); - -$schema['related_group'] = array( - // @fixme description for related_group? - 'fields' => array( - 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), - 'related_group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), - - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), - ), - 'primary key' => array('group_id', 'related_group_id'), - 'foreign keys' => array( - 'related_group_group_id_fkey' => array('user_group', array('group_id' => 'id')), - 'related_group_related_group_id_fkey' => array('user_group', array('related_group_id' => 'id')), - ), -); - -$schema['group_inbox'] = array( - 'description' => 'Many-many table listing notices posted to a given group, or which groups a given notice was posted to.', - 'fields' => array( - 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group receiving the message'), - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created'), - ), - 'primary key' => array('group_id', 'notice_id'), - 'foreign keys' => array( - 'group_inbox_group_id_fkey' => array('user_group', array('group_id' => 'id')), - 'group_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id')), - ), - 'indexes' => array( - 'group_inbox_created_idx' => array('created'), - 'group_inbox_notice_id_idx' => array('notice_id'), - ), -); - -$schema['file'] = array( - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true), - 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'destination URL after following redirections'), - 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'), - 'size' => array('type' => 'int', 'description' => 'size of resource when available'), - 'title' => array('type' => 'varchar', 'length' => 255, 'description' => 'title of resource when available'), - 'date' => array('type' => 'int', 'description' => 'date of resource according to http query'), - 'protected' => array('type' => 'int', 'description' => 'true when URL is private (needs login)'), - 'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'if a local file, name of the file'), - - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('id'), - 'unique keys' => array( - 'file_url_key' => array('url'), - ), -); - -$schema['file_oembed'] = array( - 'fields' => array( - 'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'oEmbed for that URL/file'), - 'version' => array('type' => 'varchar', 'length' => 20, 'description' => 'oEmbed spec. version'), - 'type' => array('type' => 'varchar', 'length' => 20, 'description' => 'oEmbed type: photo, video, link, rich'), - 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'), - 'provider' => array('type' => 'varchar', 'length' => 50, 'description' => 'name of this oEmbed provider'), - 'provider_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of this oEmbed provider'), - 'width' => array('type' => 'int', 'description' => 'width of oEmbed resource when available'), - 'height' => array('type' => 'int', 'description' => 'height of oEmbed resource when available'), - 'html' => array('type' => 'text', 'description' => 'html representation of this oEmbed resource when applicable'), - 'title' => array('type' => 'varchar', 'length' => 255, 'description' => 'title of oEmbed resource when available'), - 'author_name' => array('type' => 'varchar', 'length' => 50, 'description' => 'author name for this oEmbed resource'), - 'author_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'author URL for this oEmbed resource'), - 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL for this oEmbed resource when applicable (photo, link)'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('file_id'), - 'foreign keys' => array( - 'file_oembed_file_id_fkey' => array('file', array('file_id' => 'id')), - ), -); - -$schema['file_redirection'] = array( - 'fields' => array( - 'url' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'short URL (or any other kind of redirect) for file (id)'), - 'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'), - 'redirections' => array('type' => 'int', 'description' => 'redirect count'), - 'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('url'), - 'foreign keys' => array( - 'file_redirection_file_id_fkey' => array('file' => array('file_id' => 'id')), - ), -); - -$schema['file_thumbnail'] = array( - 'fields' => array( - 'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'thumbnail for what URL/file'), - 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of thumbnail'), - 'width' => array('type' => 'int', 'description' => 'width of thumbnail'), - 'height' => array('type' => 'int', 'description' => 'height of thumbnail'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('file_id'), - 'foreign keys' => array( - 'file_thumbnail_file_id_fkey' => array('file', array('file_id' => 'id')), - ), - 'unique keys' => array( - 'file_thumbnail_url_key' => array('url'), - ), -); - -$schema['file_to_post'] = array( - 'fields' => array( - 'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'), - 'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('file_id', 'post_id'), - 'foreign keys' => array( - 'file_to_post_file_id_fkey' => array('file', array('file_id' => 'id')), - 'file_to_post_post_id_fkey' => array('notice', array('post_id' => 'id')), - ), - 'indexes' => array( - 'post_id_idx' => array('post_id'), - ), -); - -$schema['group_block'] = array( - 'fields' => array( - 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'), - 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'), - 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'), - ), - 'primary key' => array('group_id', 'blocked'), - 'foreign keys' => array( - 'group_block_group_id_fkey' => array('user_group', array('group_id' => 'id')), - 'group_block_blocked_fkey' => array('profile', array('blocked' => 'id')), - 'group_block_blocker_fkey' => array('user', array('blocker' => 'id')), - ), -); - -$schema['group_alias'] = array( - 'fields' => array( - 'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'), - 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'), - ), - 'primary key' => array('alias'), - 'foreign keys' => array( - 'group_alias_group_id_fkey' => array('user_group', array('group_id' => 'id')), - ), - 'indexes' => array( - 'group_alias_group_id_idx' => array('group_id'), - ), -); - -$schema['session'] = array( - 'fields' => array( - 'id' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'), - 'session_data' => array('type' => 'text', 'description' => 'session data'), - '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( - 'session_modified_idx' => array('modified'), - ), -); - -$schema['deleted_notice'] = array( - 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity of notice'), - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'author of the notice'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice record was created'), - 'deleted' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice record was created'), - ), - 'primary key' => array('id'), - 'unique keys' => array( - 'deleted_notice_uri_key' => array('uri'), - ), - 'indexes' => array( - 'deleted_notice_profile_id_idx' => array('profile_id'), - ), -); - -$schema['config'] = array( - 'fields' => array( - 'section' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration section'), - 'setting' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration setting'), - 'value' => array('type' => 'varchar', 'length' => 255, 'description' => 'configuration value'), - ), - 'primary key' => array('section', 'setting'), -); - -$schema['profile_role'] = array( - 'fields' => array( - 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'account having the role'), - 'role' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'string representing the role'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the role was granted'), - ), - 'primary key' => array('profile_id', 'role'), - 'foreign keys' => array( - 'profile_role_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - ), -); - -$schema['location_namespace'] = array( - 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'), - 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description of the namespace'), - 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the record was created'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('id'), -); - -$schema['login_token'] = array( - 'fields' => array( - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'), - 'token' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'token useable for logging in'), - '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( - 'login_token_user_id_fkey' => array('user', array('user_id' => 'id')), - ), -); - -$schema['user_location_prefs'] = array( - 'fields' => array( - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'), - 'share_location' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Whether to share location data'), - '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_location_prefs_user_id_fkey' => array('user', array('user_id' => 'id')), - ), -); - -$schema['inbox'] = array( - 'fields' => array( - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user receiving the notice'), - 'notice_ids' => array('type' => 'blob', 'description' => 'packed list of notice ids'), - ), - 'primary key' => array('user_id'), - 'foreign keys' => array( - 'inbox_user_id_fkey' => array('user', array('user_id' => 'id')), - ), -); - -// @fixme possibly swap this for a more general prefs table? -$schema['user_im_prefs'] = array( - 'fields' => array( - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'), - 'screenname' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'screenname on this service'), - 'transport' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'), - 'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'), - 'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'), - 'microid' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'Publish a MicroID'), - 'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed 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('user_id', 'transport'), - 'unique keys' => array( - 'transport_screenname_key' => array('transport', 'screenname'), - ), - 'foreign keys' => array( - 'user_im_prefs_user_id_fkey' => array('user', array('user_id' => 'id')), - ), -); - -$schema['conversation'] = array( - 'fields' => array( - 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'uri' => array('type' => 'varchar', 'length' => 225, 'description' => 'URI of the conversation'), - '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( - 'conversation_uri_key' => array('uri'), - ), -); - -$schema['local_group'] = array( - 'description' => 'Record for a user group on the local site, with some additional info not in user_group', - 'fields' => array( - 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'), - 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'), - - '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( - 'local_group_group_id_fkey' => array('user_group', array('group_id' => 'id')), - ), - 'unique keys' => array( - 'local_group_nickname_key' => array('nickname'), - ), -); - -$schema['user_urlshortener_prefs'] = array( - 'fields' => array( - 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'), - 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'), - 'maxurllength' => array('type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, null = never'), - 'maxnoticelength' => array('type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, null = never'), - - '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_urlshortener_prefs_user_id_fkey' => array('user', array('user_id' => 'id')), - ), -); - -$schema['schema_version'] = array( - 'description' => 'To avoid checking database structure all the time, we store a checksum of the expected schema info for each table here. If it has not changed since the last time we checked the table, we can leave it as is.', - 'fields' => array( - 'table_name' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Table name'), - 'checksum' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Checksum of schema array; a mismatch indicates we should check the table more thoroughly.'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), - ), - 'primary key' => array('table_name'), -); - -$schema['group_join_queue'] = Group_join_queue::schemaDef(); - -$schema['subscription_queue'] = Subscription_queue::schemaDef(); - -$schema['oauth_token_association'] = Oauth_token_association::schemaDef(); +foreach ($classes as $cls) { + $schema[strtolower($cls)] = call_user_func(array($cls, 'schemaDef')); +} diff --git a/lib/statusnet.php b/lib/statusnet.php index 73185b1692..ce0d41e51e 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -362,13 +362,6 @@ class StatusNet $config_files); } - // Fixup for statusnet.ini - $_db_name = substr($config['db']['database'], strrpos($config['db']['database'], '/') + 1); - - if ($_db_name != 'statusnet' && !array_key_exists('ini_'.$_db_name, $config['db'])) { - $config['db']['ini_'.$_db_name] = INSTALLDIR.'/classes/statusnet.ini'; - } - // Backwards compatibility if (array_key_exists('memcached', $config)) { if ($config['memcached']['enabled']) { diff --git a/lib/util.php b/lib/util.php index f3be1d0ddc..ba705eb7fa 100644 --- a/lib/util.php +++ b/lib/util.php @@ -413,7 +413,7 @@ function common_remembered_user() return null; } - $rm = Remember_me::staticGet($code); + $rm = Remember_me::staticGet('code', $code); if (!$rm) { common_log(LOG_WARNING, 'No such remember code: ' . $code); @@ -427,7 +427,7 @@ function common_remembered_user() return null; } - $user = User::staticGet($rm->user_id); + $user = User::staticGet('id', $rm->user_id); if (!$user) { common_log(LOG_WARNING, 'No such user for rememberme: ' . $rm->user_id); diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index a2afe91f9a..023ff8e86d 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -576,6 +576,33 @@ class OpenIDPlugin extends Plugin new ColumnDef('created', 'datetime', null, false), new ColumnDef('modified', 'timestamp'))); + + /* These are used by JanRain OpenID library */ + + $schema->ensureTable('oid_associations', + array( + 'fields' => array( + 'server_url' => array('type' => 'blob', 'not null' => true), + 'handle' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), // character set latin1, + 'secret' => array('type' => 'blob'), + 'issued' => array('type' => 'int'), + 'lifetime' => array('type' => 'int'), + 'assoc_type' => array('type' => 'varchar', 'length' => 64), + ), + 'primary key' => array(array('server_url', 255), 'handle'), + )); + $schema->ensureTable('oid_nonces', + array( + 'fields' => array( + 'server_url' => array('type' => 'varchar', 'length' => 2047), + 'timestamp' => array('type' => 'int'), + 'salt' => array('type' => 'char', 'length' => 40), + ), + 'unique keys' => array( + 'oid_nonces_server_url_timestamp_salt_key' => array(array('server_url', 255), 'timestamp', 'salt'), + ), + )); + return true; }