<?php
/**
-
-Some notes...
-
-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
-
-decimal <-> numeric
-
-timestamps... how to specify?
-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?
-
-*/
+ *
+ * Some notes...
+ *
+ * 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, and PG's
+ * "bool" type isn't 100% compatible with 0/1 checks. Just keeping tinyints. :)
+ *
+ * decimal <-> numeric
+ *
+ * MySQL 'timestamp' columns were formerly used for 'modified' files for their
+ * 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
+ * have a chance to load it up again before caching.
+ *
+ * Current code should be setting 'created' and 'modified' fields explicitly;
+ * 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(
'description' => 'local and remote users have profiles',
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'indexes' => array(
'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', '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'),
'unique keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'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'),
- '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'),
'unique keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'token' => array('type' => 'varchar', 'length' => 255, 'description' => 'authorization token'),
'secret' => array('type' => 'varchar', 'length' => 255, 'description' => 'token secret'),
'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'),
'indexes' => array(
'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' => '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)'),
'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"'),
'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'),
- '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'),
);
'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'),
+ '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)'),
),
'primary key' => array('notice_id', 'profile_id'),
'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'),
- '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'),
'foreign keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('consumer_key'),
);
'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', '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'),
'foreign keys' => array(
'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', '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'),
);
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'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', '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'),
'foreign keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('code'),
'foreign keys' => 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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('code'),
'foreign keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id', 'service'),
'foreign keys' => array(
'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', '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'),
'foreign keys' => array(
'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', '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"'),
),
'primary key' => array('id'),
'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', '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'),
'foreign keys' => 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', 'description' => 'date of blocking'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date of blocking'),
),
'foreign keys' => array(
'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')),
'design_id' => array('type' => 'int', 'description' => 'id of a design'),
'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'),
'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page for group info to link to'),
'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'),
- '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'),
'foreign keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('file_id'),
'foreign keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('url'),
'foreign keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('file_id'),
'foreign keys' => 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', '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'),
'foreign keys' => 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', 'description' => 'date of blocking'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date of blocking'),
),
'primary key' => array('group_id', 'blocked'),
'foreign keys' => 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', 'description' => 'date alias was created'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date alias was created'),
),
'primary key' => array('alias'),
'foreign keys' => 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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'indexes' => 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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
);
'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', '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 keys' => 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', '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 keys' => array(
'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' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'), // @fixme will that default work?
- 'modified' => array('type' => 'timestamp', 'description' => 'date this record was modified'),
+ 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('user_id', 'transport'),
'unique keys' => 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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'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', 'description' => 'date this record was modified'),
+ 'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('group_id'),
'foreign keys' => 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'),
'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 keys' => array(