[CORE][DATABASE] Replace zero dates with CURRENT_TIMESTAMP and add defaults to all 'created' or 'modified'
This commit is a port from v2's 9a515b9234
([SCHEMA] Improve timestamp storage) to v3.
As explained by Alexei Sorokin:
Avoid the use of deprecated MariaDATABASE "zero dates" globally. If they're present
as attribute defaults somewhere, they will be replaced with NULL implicitly.
The existing "zero dates" in MariaDATABASE storage will be left intact and this
should not present any issues.
The "timestamp" type in table definitions now corresponds to DATETIME in
MariaDATABASE with "DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", which
should be close enough to the original behaviour for compatibility purposes.
It is now the recommended type for "modified" attributes, because of the
update trigger on MariaDATABASE. But there is no such trigger implemented on
PostgreSQL as of this moment.
This commit is contained in:
parent
25aeac80a3
commit
5eae3dc351
@ -37,7 +37,7 @@ use Functional as F;
|
|||||||
class SchemaDefDriver extends StaticPHPDriver
|
class SchemaDefDriver extends StaticPHPDriver
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* PEAR DB type => Doctrine type
|
* V2 DB type => Doctrine type
|
||||||
*/
|
*/
|
||||||
private const types = [
|
private const types = [
|
||||||
'varchar' => 'string',
|
'varchar' => 'string',
|
||||||
@ -50,6 +50,7 @@ class SchemaDefDriver extends StaticPHPDriver
|
|||||||
'numeric' => 'decimal',
|
'numeric' => 'decimal',
|
||||||
'text' => 'text',
|
'text' => 'text',
|
||||||
'datetime' => 'datetime',
|
'datetime' => 'datetime',
|
||||||
|
'timestamp' => 'datetime',
|
||||||
// Unused in V2, but might start being used
|
// Unused in V2, but might start being used
|
||||||
'date' => 'date',
|
'date' => 'date',
|
||||||
'time' => 'time',
|
'time' => 'time',
|
||||||
@ -98,8 +99,7 @@ class SchemaDefDriver extends StaticPHPDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$default = (($opts['default'] ?? null) === '0000-00-00 00:00:00' && $_ENV['DBMS'] === 'postgres')
|
$default = $opts['default'] ?? null;
|
||||||
? '-infinity' : $opts['default'] ?? null;
|
|
||||||
|
|
||||||
$field = [
|
$field = [
|
||||||
// boolean, optional
|
// boolean, optional
|
||||||
|
@ -124,7 +124,7 @@ class ActivityLocation
|
|||||||
'lon' => ['type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'],
|
'lon' => ['type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'],
|
||||||
'location_id' => ['type' => 'int', 'description' => 'location id if possible'],
|
'location_id' => ['type' => 'int', 'description' => 'location id if possible'],
|
||||||
'location_service' => ['type' => 'int', 'size' => 'tiny', 'description' => 'service used to retrieve location information'],
|
'location_service' => ['type' => 'int', 'size' => 'tiny', 'description' => 'service used to retrieve location information'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['activity_id'],
|
'primary key' => ['activity_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -122,8 +122,8 @@ class ActivitySource
|
|||||||
'code' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'code identifier'],
|
'code' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'code identifier'],
|
||||||
'name' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'name of the source'],
|
'name' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'name of the source'],
|
||||||
'url' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'url to link to'],
|
'url' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'url to link to'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['code'],
|
'primary key' => ['code'],
|
||||||
];
|
];
|
||||||
|
@ -86,7 +86,7 @@ class ActivityTag
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this activity'],
|
'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this activity'],
|
||||||
'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'activity tagged'],
|
'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'activity tagged'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['tag', 'activity_id'],
|
'primary key' => ['tag', 'activity_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -148,8 +148,8 @@ class Avatar
|
|||||||
'width' => ['type' => 'int', 'not null' => true, 'description' => 'image width'],
|
'width' => ['type' => 'int', 'not null' => true, 'description' => 'image width'],
|
||||||
'height' => ['type' => 'int', 'not null' => true, 'description' => 'image height'],
|
'height' => ['type' => 'int', 'not null' => true, 'description' => 'image height'],
|
||||||
'mediatype' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'],
|
'mediatype' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['profile_id', 'width', 'height'],
|
'primary key' => ['profile_id', 'width', 'height'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -149,8 +149,8 @@ class ConfirmAddress
|
|||||||
'address_extra' => ['type' => 'varchar', 'length' => 191, 'description' => 'carrier ID, for SMS'],
|
'address_extra' => ['type' => 'varchar', 'length' => 191, 'description' => 'carrier ID, for SMS'],
|
||||||
'address_type' => ['type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'],
|
'address_type' => ['type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'],
|
||||||
'claimed' => ['type' => 'datetime', 'description' => 'date this was claimed for queueing'],
|
'claimed' => ['type' => 'datetime', 'description' => 'date this was claimed for queueing'],
|
||||||
'sent' => ['type' => 'datetime', 'description' => 'date this was sent for queueing'],
|
'sent' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this was sent for queueing'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['code'],
|
'primary key' => ['code'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -108,8 +108,8 @@ class Conversation
|
|||||||
'id' => ['type' => 'serial', 'not null' => true, 'description' => 'Unique identifier, (again) unrelated to notice id since 2016-01-06'],
|
'id' => ['type' => 'serial', 'not null' => true, 'description' => 'Unique identifier, (again) unrelated to notice id since 2016-01-06'],
|
||||||
'uri' => ['type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'URI of the conversation'],
|
'uri' => ['type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'URI of the conversation'],
|
||||||
'url' => ['type' => 'varchar', 'length' => 191, 'description' => 'Resolvable URL, preferably remote (local can be generated on the fly)'],
|
'url' => ['type' => 'varchar', 'length' => 191, 'description' => 'Resolvable URL, preferably remote (local can be generated on the fly)'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
'unique keys' => [
|
'unique keys' => [
|
||||||
|
@ -215,7 +215,7 @@ class File
|
|||||||
'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'],
|
'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'],
|
||||||
'width' => ['type' => 'int', 'description' => 'width in pixels, if it can be described as such and data is available'],
|
'width' => ['type' => 'int', 'description' => 'width in pixels, if it can be described as such and data is available'],
|
||||||
'height' => ['type' => 'int', 'description' => 'height in pixels, if it can be described as such and data is available'],
|
'height' => ['type' => 'int', 'description' => 'height in pixels, if it can be described as such and data is available'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
'unique keys' => [
|
'unique keys' => [
|
||||||
|
@ -134,7 +134,7 @@ class FileThumbnail
|
|||||||
'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'thumbnail for what file'],
|
'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'thumbnail for what file'],
|
||||||
'width' => ['type' => 'int', 'not null' => true, 'description' => 'width of thumbnail'],
|
'width' => ['type' => 'int', 'not null' => true, 'description' => 'width of thumbnail'],
|
||||||
'height' => ['type' => 'int', 'not null' => true, 'description' => 'height of thumbnail'],
|
'height' => ['type' => 'int', 'not null' => true, 'description' => 'height of thumbnail'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['file_id', 'width', 'height'],
|
'primary key' => ['file_id', 'width', 'height'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -85,7 +85,7 @@ class FileToActivity
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of file'],
|
'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of file'],
|
||||||
'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of the activity it belongs to'],
|
'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of the activity it belongs to'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['file_id', 'activity_id'],
|
'primary key' => ['file_id', 'activity_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -86,7 +86,7 @@ class FollowQueue
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'follower' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'],
|
'follower' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'],
|
||||||
'followed' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile being followed to'],
|
'followed' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile being followed to'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['follower', 'followed'],
|
'primary key' => ['follower', 'followed'],
|
||||||
'indexes' => [
|
'indexes' => [
|
||||||
|
@ -263,12 +263,12 @@ class Group
|
|||||||
'homepage_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'homepage (profile) size logo'],
|
'homepage_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'homepage (profile) size logo'],
|
||||||
'stream_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'],
|
'stream_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'],
|
||||||
'mini_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'mini logo'],
|
'mini_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'mini logo'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
|
||||||
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'],
|
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'],
|
||||||
'mainpage' => ['type' => 'varchar', 'length' => 191, 'description' => 'page for group info to link to'],
|
'mainpage' => ['type' => 'varchar', 'length' => 191, 'description' => 'page for group info to link to'],
|
||||||
'join_policy' => ['type' => 'int', 'size' => 'tiny', 'description' => '0=open; 1=requires admin approval'],
|
'join_policy' => ['type' => 'int', 'size' => 'tiny', 'description' => '0=open; 1=requires admin approval'],
|
||||||
'force_scope' => ['type' => 'int', 'size' => 'tiny', 'description' => '0=never,1=sometimes,-1=always'],
|
'force_scope' => ['type' => 'int', 'size' => 'tiny', 'description' => '0=never,1=sometimes,-1=always'],
|
||||||
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
'unique keys' => [
|
'unique keys' => [
|
||||||
|
@ -85,7 +85,7 @@ class GroupAlias
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'alias' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'],
|
'alias' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'],
|
||||||
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group id which this is an alias of'],
|
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group id which this is an alias of'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['alias'],
|
'primary key' => ['alias'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -98,7 +98,7 @@ class GroupBlock
|
|||||||
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'],
|
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'],
|
||||||
'blocked_profile' => ['type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'],
|
'blocked_profile' => ['type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'],
|
||||||
'blocker_user' => ['type' => 'int', 'not null' => true, 'description' => 'user making the block'],
|
'blocker_user' => ['type' => 'int', 'not null' => true, 'description' => 'user making the block'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['group_id', 'blocked_profile'],
|
'primary key' => ['group_id', 'blocked_profile'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -86,7 +86,7 @@ class GroupInbox
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group receiving the message'],
|
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group receiving the message'],
|
||||||
'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'activity received'],
|
'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'activity received'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the activity was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['group_id', 'activity_id'],
|
'primary key' => ['group_id', 'activity_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -86,7 +86,7 @@ class GroupJoinQueue
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'],
|
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'],
|
||||||
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local group to join, if any'],
|
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local group to join, if any'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['profile_id', 'group_id'],
|
'primary key' => ['profile_id', 'group_id'],
|
||||||
'indexes' => [
|
'indexes' => [
|
||||||
|
@ -123,8 +123,8 @@ class GroupMember
|
|||||||
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'],
|
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'],
|
||||||
'is_admin' => ['type' => 'bool', 'default' => false, 'description' => 'is this user an admin?'],
|
'is_admin' => ['type' => 'bool', 'default' => false, 'description' => 'is this user an admin?'],
|
||||||
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'],
|
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['group_id', 'profile_id'],
|
'primary key' => ['group_id', 'profile_id'],
|
||||||
'unique keys' => [
|
'unique keys' => [
|
||||||
|
@ -123,8 +123,8 @@ class Invitation
|
|||||||
'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'],
|
'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'],
|
||||||
'address' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'invitation sent to'],
|
'address' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'invitation sent to'],
|
||||||
'address_type' => ['type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'],
|
'address_type' => ['type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
|
||||||
'registered_user_id' => ['type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'],
|
'registered_user_id' => ['type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'],
|
||||||
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['code'],
|
'primary key' => ['code'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -97,8 +97,8 @@ class LocationService
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'id' => ['type' => 'int', 'size' => 'tiny', 'not null' => true, 'description' => 'identifier for the location service'],
|
'id' => ['type' => 'int', 'size' => 'tiny', 'not null' => true, 'description' => 'identifier for the location service'],
|
||||||
'description' => ['type' => 'varchar', 'length' => 191, 'description' => 'description of the service'],
|
'description' => ['type' => 'varchar', 'length' => 191, 'description' => 'description of the service'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
];
|
];
|
||||||
|
@ -111,8 +111,8 @@ class Notification
|
|||||||
'notice_id' => ['type' => 'int', 'not null' => true, 'description' => 'notice_id to give attention'],
|
'notice_id' => ['type' => 'int', 'not null' => true, 'description' => 'notice_id to give attention'],
|
||||||
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'profile_id for feed receiver'],
|
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'profile_id for feed receiver'],
|
||||||
'reason' => ['type' => 'varchar', 'length' => 191, 'description' => 'Optional reason why this was brought to the attention of profile_id'],
|
'reason' => ['type' => 'varchar', 'length' => 191, 'description' => 'Optional reason why this was brought to the attention of profile_id'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['notice_id', 'profile_id'],
|
'primary key' => ['notice_id', 'profile_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -214,8 +214,8 @@ class Profile
|
|||||||
'lon' => ['type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'],
|
'lon' => ['type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'],
|
||||||
'location_id' => ['type' => 'int', 'description' => 'location id if possible'],
|
'location_id' => ['type' => 'int', 'description' => 'location id if possible'],
|
||||||
'location_service' => ['type' => 'int', 'description' => 'service used to obtain location id'],
|
'location_service' => ['type' => 'int', 'description' => 'service used to obtain location id'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
'indexes' => [
|
'indexes' => [
|
||||||
|
@ -85,7 +85,7 @@ class ProfileBlock
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'blocker' => ['type' => 'int', 'not null' => true, 'description' => 'user making the block'],
|
'blocker' => ['type' => 'int', 'not null' => true, 'description' => 'user making the block'],
|
||||||
'blocked' => ['type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'],
|
'blocked' => ['type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['blocker', 'blocked'],
|
'primary key' => ['blocker', 'blocked'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -189,8 +189,8 @@ class ProfileList
|
|||||||
'mainpage' => ['type' => 'varchar', 'length' => 191, 'description' => 'page to link to'],
|
'mainpage' => ['type' => 'varchar', 'length' => 191, 'description' => 'page to link to'],
|
||||||
'tagged_count' => ['type' => 'int', 'default' => 0, 'description' => 'number of people tagged with this tag by this user'],
|
'tagged_count' => ['type' => 'int', 'default' => 0, 'description' => 'number of people tagged with this tag by this user'],
|
||||||
'follower_count' => ['type' => 'int', 'default' => 0, 'description' => 'number of followers to this tag'],
|
'follower_count' => ['type' => 'int', 'default' => 0, 'description' => 'number of followers to this tag'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the tag was added'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['tagger', 'tag'],
|
'primary key' => ['tagger', 'tag'],
|
||||||
'unique keys' => [
|
'unique keys' => [
|
||||||
|
@ -123,8 +123,8 @@ class ProfilePrefs
|
|||||||
'namespace' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'namespace, like pluginname or category'],
|
'namespace' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'namespace, like pluginname or category'],
|
||||||
'topic' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'preference key, i.e. description, age...'],
|
'topic' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'preference key, i.e. description, age...'],
|
||||||
'data' => ['type' => 'blob', 'description' => 'topic data, may be anything'],
|
'data' => ['type' => 'blob', 'description' => 'topic data, may be anything'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['profile_id', 'namespace', 'topic'],
|
'primary key' => ['profile_id', 'namespace', 'topic'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -98,7 +98,7 @@ class ProfileTag
|
|||||||
'tagger' => ['type' => 'int', 'not null' => true, 'description' => 'user making the tag'],
|
'tagger' => ['type' => 'int', 'not null' => true, 'description' => 'user making the tag'],
|
||||||
'tagged' => ['type' => 'int', 'not null' => true, 'description' => 'profile tagged'],
|
'tagged' => ['type' => 'int', 'not null' => true, 'description' => 'profile tagged'],
|
||||||
'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'],
|
'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'],
|
||||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was added'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['tagger', 'tagged', 'tag'],
|
'primary key' => ['tagger', 'tagged', 'tag'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -97,8 +97,8 @@ class ProfileTagFollow
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'profile_tag_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'],
|
'profile_tag_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'],
|
||||||
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'],
|
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['profile_tag_id', 'profile_id'],
|
'primary key' => ['profile_tag_id', 'profile_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -86,7 +86,7 @@ class RelatedGroup
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'],
|
'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'],
|
||||||
'related_group_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'],
|
'related_group_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['group_id', 'related_group_id'],
|
'primary key' => ['group_id', 'related_group_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -73,7 +73,7 @@ class ReservedNickname
|
|||||||
'description' => 'A reserved nickname',
|
'description' => 'A reserved nickname',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'nickname' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname not to use'],
|
'nickname' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname not to use'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['nickname'],
|
'primary key' => ['nickname'],
|
||||||
];
|
];
|
||||||
|
@ -110,8 +110,8 @@ class SmsCarrier
|
|||||||
'id' => ['type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'],
|
'id' => ['type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'],
|
||||||
'name' => ['type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'],
|
'name' => ['type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'],
|
||||||
'email_pattern' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'],
|
'email_pattern' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
'unique keys' => [
|
'unique keys' => [
|
||||||
|
@ -95,8 +95,8 @@ class UserLocationPrefs
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'user who has the preference'],
|
'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'user who has the preference'],
|
||||||
'share_location' => ['type' => 'bool', 'default' => true, 'description' => 'Whether to share location data'],
|
'share_location' => ['type' => 'bool', 'default' => true, 'description' => 'Whether to share location data'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['user_id'],
|
'primary key' => ['user_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
@ -153,8 +153,8 @@ class UserNotificationPrefs
|
|||||||
'dm' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Notify someone sends us a direct message'],
|
'dm' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Notify someone sends us a direct message'],
|
||||||
'post_on_status_change' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Post a notice when our status in service changes'],
|
'post_on_status_change' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Post a notice when our status in service changes'],
|
||||||
'enable_posting' => ['type' => 'bool', 'default' => true, 'description' => 'Enable posting from this service'],
|
'enable_posting' => ['type' => 'bool', 'default' => true, 'description' => 'Enable posting from this service'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['user_id', 'transport'],
|
'primary key' => ['user_id', 'transport'],
|
||||||
'unique keys' => [
|
'unique keys' => [
|
||||||
|
@ -123,8 +123,8 @@ class UserUrlShortenerPrefs
|
|||||||
'url_shortening_service' => ['type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'],
|
'url_shortening_service' => ['type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'],
|
||||||
'max_url_length' => ['type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, -1 = never'],
|
'max_url_length' => ['type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, -1 = never'],
|
||||||
'max_notice_length' => ['type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, -1 = only if notice text is longer than max allowed'],
|
'max_notice_length' => ['type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, -1 = only if notice text is longer than max allowed'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['user_id'],
|
'primary key' => ['user_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
|
Loading…
Reference in New Issue
Block a user