Normalize the 'modified' vs 'created' field definitions to not-null timestamps. We can't rely on database DEFAULT or ON UPDATE values, since they don't play well with our insert-time caching.

This commit is contained in:
Brion Vibber 2010-10-18 17:08:23 -07:00
parent f1bfbece06
commit 54bac12eb9

View File

@ -1,24 +1,32 @@
<?php <?php
/** /**
*
Some notes... * Some notes...
*
drupal docs don't list a bool type, but it might be nice to use rather than 'tinyint' * Drupal docs don't list a bool type, but it might be nice to use rather than 'tinyint'
note however that we use bitfields and things as well in tinyints * Note however that we use bitfields and things as well in tinyints, and PG's
* "bool" type isn't 100% compatible with 0/1 checks. Just keeping tinyints. :)
decimal <-> numeric *
* decimal <-> numeric
timestamps... how to specify? *
fulltext indexes? * MySQL 'timestamp' columns were formerly used for 'modified' files for their
got one or two things wanting a custom charset setting on a field? * auto-updating properties. This didn't play well with changes to cache usage
* in 0.9.x, as we don't know the timestamp value at INSERT time and never
foreign keys are kinda funky... * have a chance to load it up again before caching.
those specified in inline syntax (as all in the original .sql) are NEVER ENFORCED on mysql *
those made with an explicit 'foreign key' WITHIN INNODB and IF there's a proper index, do get enforced * Current code should be setting 'created' and 'modified' fields explicitly;
double-check what we've been doing on postgres? * this also avoids mismatches between server and client timezone settings.
*
*/ *
* fulltext indexes?
* got one or two things wanting a custom charset setting on a field?
*
* foreign keys are kinda funky...
* those specified in inline syntax (as all in the original .sql) are NEVER ENFORCED on mysql
* those made with an explicit 'foreign key' WITHIN INNODB and IF there's a proper index, do get enforced
* double-check what we've been doing on postgres?
*/
$schema['profile'] = array( $schema['profile'] = array(
'description' => 'local and remote users have profiles', 'description' => 'local and remote users have profiles',
@ -36,7 +44,7 @@ $schema['profile'] = array(
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'), 'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'indexes' => array( 'indexes' => array(
@ -57,7 +65,7 @@ $schema['avatar'] = array(
'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'local filename, if local'), 'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'local filename, if local'),
'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'avatar location'), 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'avatar location'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('profile_id', 'width', 'height'), 'primary key' => array('profile_id', 'width', 'height'),
'unique keys' => array( 'unique keys' => array(
@ -77,7 +85,7 @@ $schema['sms_carrier'] = array(
'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the 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'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -115,7 +123,7 @@ $schema['user'] = array(
'viewdesigns' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'whether to view user-provided designs'), 'viewdesigns' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'whether to view user-provided designs'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -143,7 +151,7 @@ $schema['remote_profile'] = array(
'postnoticeurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL we use for posting notices'), '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'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -163,7 +171,7 @@ $schema['subscription'] = array(
'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'authorization token'), 'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'authorization token'),
'secret' => array('type' => 'varchar', 'length' => 255, 'description' => 'token secret'), 'secret' => array('type' => 'varchar', 'length' => 255, 'description' => 'token secret'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('subscriber', 'subscribed'), 'primary key' => array('subscriber', 'subscribed'),
'indexes' => array( 'indexes' => array(
@ -182,7 +190,7 @@ $schema['notice'] = array(
'rendered' => array('type' => 'text', 'description' => 'HTML version of the 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)'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
'reply_to' => array('type' => 'int', 'description' => 'notice replied to (usually a guess)'), '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'), '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"'), 'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'),
@ -221,7 +229,7 @@ $schema['notice_source'] = array(
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'name of the source'), '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'), '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'), 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('code'), 'primary key' => array('code'),
); );
@ -230,7 +238,7 @@ $schema['reply'] = array(
'fields' => array( 'fields' => array(
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'), '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'), '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'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'), 'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'),
), ),
'primary key' => array('notice_id', 'profile_id'), 'primary key' => array('notice_id', 'profile_id'),
@ -249,7 +257,7 @@ $schema['fave'] = array(
'fields' => array( 'fields' => array(
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the favorite'), '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'), 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who likes this notice'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('notice_id', 'user_id'), 'primary key' => array('notice_id', 'user_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -273,7 +281,7 @@ $schema['consumer'] = array(
'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('consumer_key'), 'primary key' => array('consumer_key'),
); );
@ -290,7 +298,7 @@ $schema['token'] = array(
'verified_callback' => array('type' => 'varchar', 'length' => 255, 'description' => 'verified callback URL 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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('consumer_key', 'tok'), 'primary key' => array('consumer_key', 'tok'),
'foreign keys' => array( 'foreign keys' => array(
@ -307,7 +315,7 @@ $schema['nonce'] = array(
'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'), 'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('consumer_key', 'ts', 'nonce'), 'primary key' => array('consumer_key', 'ts', 'nonce'),
); );
@ -328,7 +336,7 @@ $schema['oauth_application'] = array(
'type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'type of app, 1 = browser, 2 = desktop'), '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'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -347,7 +355,7 @@ $schema['oauth_application_user'] = array(
'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'access type, bit 1 = read, bit 2 = write'), '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'), 'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'request or access token'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('profile_id', 'application_id'), 'primary key' => array('profile_id', 'application_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -390,7 +398,7 @@ $schema['confirm_address'] = array(
'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "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'), 'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'),
'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'), 'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('code'), 'primary key' => array('code'),
'foreign keys' => array( 'foreign keys' => array(
@ -402,7 +410,7 @@ $schema['remember_me'] = array(
'fields' => array( 'fields' => array(
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'), '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'), 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who is logged in'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('code'), 'primary key' => array('code'),
'foreign keys' => array( 'foreign keys' => array(
@ -449,7 +457,7 @@ $schema['foreign_service'] = array(
'name' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'), 'name' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'),
'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description'), 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -464,7 +472,7 @@ $schema['foreign_user'] = array(
'uri' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'identifying URI'), 'uri' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'identifying URI'),
'nickname' => array('type' => 'varchar', 'length' => 255, 'description' => 'nickname on foreign service'), 'nickname' => array('type' => 'varchar', 'length' => 255, 'description' => 'nickname on foreign service'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id', 'service'), 'primary key' => array('id', 'service'),
'foreign keys' => array( 'foreign keys' => array(
@ -488,7 +496,7 @@ $schema['foreign_link'] = array(
'last_noticesync' => array('type' => 'datetime', 'description' => 'last time notices were imported'), 'last_noticesync' => array('type' => 'datetime', 'description' => 'last time notices were imported'),
'last_friendsync' => array('type' => 'datetime', 'description' => 'last time friends 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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('user_id', 'foreign_id', 'service'), 'primary key' => array('user_id', 'foreign_id', 'service'),
'foreign keys' => array( 'foreign keys' => array(
@ -548,7 +556,7 @@ $schema['message'] = array(
'rendered' => array('type' => 'text', 'description' => 'HTML version of the 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)'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'), 'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
@ -591,7 +599,7 @@ $schema['profile_tag'] = array(
'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'), 'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'),
'tagged' => array('type' => 'int', 'not null' => true, 'description' => 'profile tagged'), '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'), 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
'modified' => array('type' => 'timestamp', 'description' => 'date the tag was added'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the tag was added'),
), ),
'primary key' => array('tagger', 'tagged', 'tag'), 'primary key' => array('tagger', 'tagged', 'tag'),
'foreign keys' => array( 'foreign keys' => array(
@ -609,7 +617,7 @@ $schema['profile_block'] = array(
'fields' => array( 'fields' => array(
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'), 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
'modified' => array('type' => 'timestamp', 'description' => 'date of blocking'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date of blocking'),
), ),
'foreign keys' => array( 'foreign keys' => array(
'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')), 'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')),
@ -635,7 +643,7 @@ $schema['user_group'] = array(
'design_id' => array('type' => 'int', 'description' => 'id of a design'), 'design_id' => array('type' => 'int', 'description' => 'id of a design'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'),
'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page for group info to link to'), 'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page for group info to link to'),
@ -659,7 +667,7 @@ $schema['group_member'] = array(
'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'), 'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('group_id', 'profile_id'), 'primary key' => array('group_id', 'profile_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -717,7 +725,7 @@ $schema['file'] = array(
'protected' => array('type' => 'int', 'description' => 'true when URL is private (needs login)'), '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'), 'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'if a local file, name of the file'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -740,7 +748,7 @@ $schema['file_oembed'] = array(
'author_name' => array('type' => 'varchar', 'length' => 50, 'description' => 'author name for this oEmbed resource'), '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'), '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)'), 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL for this oEmbed resource when applicable (photo, link)'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('file_id'), 'primary key' => array('file_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -754,7 +762,7 @@ $schema['file_redirection'] = array(
'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'), 'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'),
'redirections' => array('type' => 'int', 'description' => 'redirect count'), 'redirections' => array('type' => 'int', 'description' => 'redirect count'),
'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'), 'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('url'), 'primary key' => array('url'),
'foreign keys' => array( 'foreign keys' => array(
@ -768,7 +776,7 @@ $schema['file_thumbnail'] = array(
'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of thumbnail'), 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of thumbnail'),
'width' => array('type' => 'int', 'description' => 'width of thumbnail'), 'width' => array('type' => 'int', 'description' => 'width of thumbnail'),
'height' => array('type' => 'int', 'description' => 'height of thumbnail'), 'height' => array('type' => 'int', 'description' => 'height of thumbnail'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('file_id'), 'primary key' => array('file_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -783,7 +791,7 @@ $schema['file_to_post'] = array(
'fields' => array( 'fields' => array(
'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'), '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'), 'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('file_id', 'post_id'), 'primary key' => array('file_id', 'post_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -814,7 +822,7 @@ $schema['group_block'] = array(
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'), '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'), 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
'modified' => array('type' => 'timestamp', 'description' => 'date of blocking'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date of blocking'),
), ),
'primary key' => array('group_id', 'blocked'), 'primary key' => array('group_id', 'blocked'),
'foreign keys' => array( 'foreign keys' => array(
@ -828,7 +836,7 @@ $schema['group_alias'] = array(
'fields' => array( 'fields' => array(
'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'), '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'), 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
'modified' => array('type' => 'timestamp', 'description' => 'date alias was created'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date alias was created'),
), ),
'primary key' => array('alias'), 'primary key' => array('alias'),
'foreign keys' => array( 'foreign keys' => array(
@ -844,7 +852,7 @@ $schema['session'] = array(
'id' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'), 'id' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'),
'session_data' => array('type' => 'text', 'description' => 'session data'), 'session_data' => array('type' => 'text', 'description' => 'session data'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'indexes' => array( 'indexes' => array(
@ -895,7 +903,7 @@ $schema['location_namespace'] = array(
'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'), 'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'),
'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description of the 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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
); );
@ -905,7 +913,7 @@ $schema['login_token'] = array(
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'), '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'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('user_id'), 'primary key' => array('user_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -918,7 +926,7 @@ $schema['user_location_prefs'] = array(
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'), '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'), '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('user_id'), 'primary key' => array('user_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -947,8 +955,8 @@ $schema['user_im_prefs'] = array(
'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'), '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'), '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.'), 'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to.'),
'created' => array('type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'), // @fixme will that default work? 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('user_id', 'transport'), 'primary key' => array('user_id', 'transport'),
'unique keys' => array( 'unique keys' => array(
@ -964,7 +972,7 @@ $schema['conversation'] = array(
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
'uri' => array('type' => 'varchar', 'length' => 225, 'description' => 'URI of the conversation'), 'uri' => array('type' => 'varchar', 'length' => 225, 'description' => 'URI of the conversation'),
'created' => array('type' => 'datetime', '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', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
@ -979,7 +987,7 @@ $schema['local_group'] = array(
'nickname' => array('type' => 'varchar', 'length' => 64, '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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('group_id'), 'primary key' => array('group_id'),
'foreign keys' => array( 'foreign keys' => array(
@ -998,7 +1006,7 @@ $schema['user_urlshortener_prefs'] = array(
'maxnoticelength' => array('type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls 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'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'), 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
), ),
'primary key' => array('user_id'), 'primary key' => array('user_id'),
'foreign keys' => array( 'foreign keys' => array(