[CORE] Bump Database requirement to MariaDB 10.3+

This commit is contained in:
Diogo Cordeiro 2019-07-25 00:43:25 +01:00
parent 7044f0e2cf
commit f67a93eddc
62 changed files with 472 additions and 478 deletions

View File

@ -23,8 +23,8 @@ class Attention extends Managed_DataObject
public $notice_id; // int(4) primary_key not_null
public $profile_id; // int(4) primary_key not_null
public $reason; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -34,8 +34,8 @@ class Attention extends Managed_DataObject
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice_id to give attention'),
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile_id for feed receiver'),
'reason' => array('type' => 'varchar', 'length' => 191, 'description' => 'Optional reason why this was brought to the attention of profile_id'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('notice_id', 'profile_id'),
'foreign keys' => array(

View File

@ -15,8 +15,8 @@ class Avatar extends Managed_DataObject
public $height; // int(4) primary_key not_null
public $mediatype; // varchar(32) not_null
public $filename; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -28,8 +28,8 @@ class Avatar extends Managed_DataObject
'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'),
'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'),
'filename' => array('type' => 'varchar', 'length' => 191, 'description' => 'local filename, if local'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('profile_id', 'width', 'height'),
'unique keys' => array(

View File

@ -13,7 +13,7 @@ class Confirm_address extends Managed_DataObject
public $address_type; // varchar(8) not_null
public $claimed; // datetime()
public $sent; // datetime()
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -26,7 +26,7 @@ class Confirm_address extends Managed_DataObject
'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'),
'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('code'),
'foreign keys' => array(

View File

@ -13,8 +13,8 @@ class Consumer extends Managed_DataObject
public $consumer_key; // varchar(191) primary_key not_null not 255 because utf8mb4 takes more space
public $consumer_secret; // varchar(191) not_null not 255 because utf8mb4 takes more space
public $seed; // char(32) not_null
public $created; // datetime not_null
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -27,9 +27,8 @@ class Consumer extends Managed_DataObject
'consumer_key' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'unique identifier, root URL'),
'consumer_secret' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'secret value'),
'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('consumer_key'),
);

View File

@ -37,8 +37,8 @@ class Conversation extends Managed_DataObject
public $id; // int(4) primary_key not_null auto_increment
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
public $url; // varchar(191) unique_key not 255 because utf8mb4 takes more space
public $created; // datetime not_null
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -47,8 +47,8 @@ class Conversation extends Managed_DataObject
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'Unique identifier, (again) unrelated to notice id since 2016-01-06'),
'uri' => array('type' => 'varchar', 'not null'=>true, 'length' => 191, 'description' => 'URI of the conversation'),
'url' => array('type' => 'varchar', 'length' => 191, 'description' => 'Resolvable URL, preferrably remote (local can be generated on the fly)'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(

View File

@ -46,7 +46,7 @@ class File extends Managed_DataObject
public $filename; // text()
public $width; // int(4)
public $height; // int(4)
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
const URLHASH_ALG = 'sha256';
const FILEHASH_ALG = 'sha256';
@ -67,8 +67,7 @@ class File extends Managed_DataObject
'filename' => array('type' => 'text', 'description' => 'if file is stored locally (too) this is the filename'),
'width' => array('type' => 'int', 'description' => 'width in pixels, if it can be described as such and data is available'),
'height' => array('type' => 'int', 'description' => 'height in pixels, if it can be described as such and data is available'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(

View File

@ -34,7 +34,7 @@ class File_redirection extends Managed_DataObject
public $file_id; // int(4)
public $redirections; // int(4)
public $httpcode; // int(4)
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -50,7 +50,7 @@ class File_redirection extends Managed_DataObject
'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'),
'redirections' => array('type' => 'int', 'description' => 'redirect count'),
'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('urlhash'),
'foreign keys' => array(

View File

@ -32,7 +32,7 @@ class File_thumbnail extends Managed_DataObject
public $filename; // text
public $width; // int(4) primary_key
public $height; // int(4) primary_key
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
const URLHASH_ALG = 'sha256';
@ -46,7 +46,7 @@ class File_thumbnail extends Managed_DataObject
'filename' => array('type' => 'text', 'description' => 'if stored locally, filename is put here'),
'width' => array('type' => 'int', 'description' => 'width of thumbnail'),
'height' => array('type' => 'int', 'description' => 'height of thumbnail'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('file_id', 'width', 'height'),
'indexes' => array(

View File

@ -31,7 +31,7 @@ class File_to_post extends Managed_DataObject
public $__table = 'file_to_post'; // table name
public $file_id; // int(4) primary_key not_null
public $post_id; // int(4) primary_key not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -42,7 +42,7 @@ class File_to_post extends Managed_DataObject
'fields' => array(
'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'),
'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('file_id', 'post_id'),
'foreign keys' => array(

View File

@ -19,8 +19,8 @@ class Foreign_link extends Managed_DataObject
public $profilesync; // tinyint(1) not_null default_1
public $last_noticesync; // datetime()
public $last_friendsync; // datetime()
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -38,8 +38,8 @@ class Foreign_link extends Managed_DataObject
'profilesync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'),
'last_noticesync' => array('type' => 'datetime', 'description' => 'last time notices were imported'),
'last_friendsync' => array('type' => 'datetime', 'description' => 'last time friends were imported'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('user_id', 'foreign_id', 'service'),
'foreign keys' => array(

View File

@ -13,8 +13,8 @@ class Foreign_service extends Managed_DataObject
public $id; // int(4) primary_key not_null
public $name; // varchar(32) unique_key not_null
public $description; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -26,8 +26,8 @@ class Foreign_service extends Managed_DataObject
'id' => array('type' => 'int', 'not null' => true, 'description' => 'numeric key for service'),
'name' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'),
'description' => array('type' => 'varchar', 'length' => 191, 'description' => 'description'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(

View File

@ -13,7 +13,7 @@ class Foreign_subscription extends Managed_DataObject
public $service; // int(4) primary_key not_null
public $subscriber; // int(4) primary_key not_null
public $subscribed; // int(4) primary_key not_null
public $created; // datetime() not_null
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -26,7 +26,7 @@ class Foreign_subscription extends Managed_DataObject
'service' => array('type' => 'int', 'not null' => true, 'description' => 'service where relationship happens'),
'subscriber' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscriber on foreign service'),
'subscribed' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscribed user'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
),
'primary key' => array('service', 'subscriber', 'subscribed'),
'foreign keys' => array(

View File

@ -14,8 +14,8 @@ class Foreign_user extends Managed_DataObject
public $service; // int(4) primary_key not_null
public $uri; // varchar(191) unique_key not_null not 255 because utf8mb4 takes more space
public $nickname; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -28,8 +28,8 @@ class Foreign_user extends Managed_DataObject
'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'),
'nickname' => array('type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id', 'service'),
'foreign keys' => array(

View File

@ -31,7 +31,7 @@ class Group_alias extends Managed_DataObject
public $__table = 'group_alias'; // table name
public $alias; // varchar(64) primary_key not_null
public $group_id; // int(4) not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -42,7 +42,7 @@ class Group_alias extends Managed_DataObject
'fields' => array(
'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'),
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date alias was created'),
),
'primary key' => array('alias'),
'foreign keys' => array(

View File

@ -32,7 +32,7 @@ class Group_block extends Managed_DataObject
public $group_id; // int(4) primary_key not_null
public $blocked; // int(4) primary_key not_null
public $blocker; // int(4) not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -44,7 +44,7 @@ class Group_block extends Managed_DataObject
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date of blocking'),
),
'primary key' => array('group_id', 'blocked'),
'foreign keys' => array(

View File

@ -11,7 +11,7 @@ class Group_inbox extends Managed_DataObject
public $__table = 'group_inbox'; // table name
public $group_id; // int(4) primary_key not_null
public $notice_id; // int(4) primary_key not_null
public $created; // datetime() not_null
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -23,7 +23,7 @@ class Group_inbox extends Managed_DataObject
'fields' => array(
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group receiving the message'),
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the notice was created'),
),
'primary key' => array('group_id', 'notice_id'),
'foreign keys' => array(

View File

@ -24,7 +24,7 @@ class Group_join_queue extends Managed_DataObject
'fields' => array(
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
'group_id' => array('type' => 'int', 'description' => 'remote or local group to join, if any'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
),
'primary key' => array('profile_id', 'group_id'),
'indexes' => array(

View File

@ -13,8 +13,8 @@ class Group_member extends Managed_DataObject
public $profile_id; // int(4) primary_key not_null
public $is_admin; // tinyint(1)
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -27,8 +27,8 @@ class Group_member extends Managed_DataObject
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'),
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('group_id', 'profile_id'),
'unique keys' => array(

View File

@ -15,7 +15,7 @@ class Invitation extends Managed_DataObject
public $address; // varchar(191) multiple_key not_null not 255 because utf8mb4 takes more space
public $address_type; // varchar(8) multiple_key not_null
public $registered_user_id; // int(4) not_null
public $created; // datetime() not_null
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -36,7 +36,7 @@ class Invitation extends Managed_DataObject
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'),
'address' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'invitation sent to'),
'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'registered_user_id' => array('type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'),
),
'primary key' => array('code'),

View File

@ -11,8 +11,8 @@ class Local_group extends Managed_DataObject
public $__table = 'local_group'; // table name
public $group_id; // int(4) primary_key not_null
public $nickname; // varchar(64) unique_key
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -24,9 +24,8 @@ class Local_group extends Managed_DataObject
'fields' => array(
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'),
'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('group_id'),
'foreign keys' => array(

View File

@ -33,8 +33,8 @@ class Location_namespace extends Managed_DataObject
public $__table = 'location_namespace'; // table name
public $id; // int(4) primary_key not_null
public $description; // varchar(191)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -45,8 +45,8 @@ class Location_namespace extends Managed_DataObject
'fields' => array(
'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'),
'description' => array('type' => 'varchar', 'length' => 191, 'description' => 'description of the namespace'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
);

View File

@ -31,8 +31,8 @@ class Login_token extends Managed_DataObject
public $__table = 'login_token'; // table name
public $user_id; // int(4) primary_key not_null
public $token; // char(32) not_null
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -43,8 +43,8 @@ class Login_token extends Managed_DataObject
'fields' => array(
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'),
'token' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'token useable for logging in'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('user_id'),
'foreign keys' => array(

View File

@ -14,8 +14,8 @@ class Nonce extends Managed_DataObject
public $tok; // char(32)
public $nonce; // char(32) primary_key not_null
public $ts; // datetime() primary_key not_null
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -43,9 +43,8 @@ class Nonce extends Managed_DataObject
'tok' => array('type' => 'char', 'length' => 32, 'description' => 'buggy old value, ignored'),
'nonce' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'nonce'),
'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('consumer_key', 'ts', 'nonce'),
);

View File

@ -59,8 +59,8 @@ class Notice extends Managed_DataObject
public $content; // text
public $rendered; // text
public $url; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime multiple_key not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() multiple_key not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public $reply_to; // int(4)
public $is_local; // int(4)
public $source; // varchar(32)
@ -83,8 +83,8 @@ class Notice extends Managed_DataObject
'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8mb4_general_ci'),
'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
'url' => array('type' => 'varchar', 'length' => 191, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', '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"'),

View File

@ -11,7 +11,7 @@ class Notice_location extends Managed_DataObject
public $lon; // decimal(10,7)
public $location_id; // int(4)
public $location_ns; // int(4)
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -22,7 +22,7 @@ class Notice_location extends Managed_DataObject
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('notice_id'),
'foreign keys' => array(

View File

@ -34,8 +34,8 @@ class Notice_prefs extends Managed_DataObject
public $namespace; // varchar(191) not_null
public $topic; // varchar(191) not_null
public $data; // text
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -45,8 +45,8 @@ class Notice_prefs extends Managed_DataObject
'namespace' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'namespace, like pluginname or category'),
'topic' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'preference key, i.e. description, age...'),
'data' => array('type' => 'blob', 'description' => 'topic data, may be anything'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('notice_id', 'namespace', 'topic'),
'foreign keys' => array(

View File

@ -13,8 +13,8 @@ class Notice_source extends Managed_DataObject
public $code; // varchar(32) primary_key not_null
public $name; // varchar(191) not_null not 255 because utf8mb4 takes more space
public $url; // varchar(191) not_null not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -27,8 +27,8 @@ class Notice_source extends Managed_DataObject
'name' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'name of the source'),
'url' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'url to link to'),
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('code'),
);

View File

@ -27,7 +27,7 @@ class Notice_tag extends Managed_DataObject
public $__table = 'notice_tag'; // table name
public $tag; // varchar(64) primary_key not_null
public $notice_id; // int(4) primary_key not_null
public $created; // datetime() not_null
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -39,7 +39,7 @@ class Notice_tag extends Managed_DataObject
'fields' => array(
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice tagged'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
),
'primary key' => array('tag', 'notice_id'),
'foreign keys' => array(

View File

@ -22,8 +22,8 @@ class Oauth_application extends Managed_DataObject
public $callback_url; // varchar(191) not_null not 255 because utf8mb4 takes more space
public $type; // tinyint(1)
public $access_type; // tinyint(1)
public $created; // datetime not_null
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -173,8 +173,8 @@ class Oauth_application extends Managed_DataObject
'callback_url' => array('type' => 'varchar', 'length' => 191, 'description' => 'url to redirect to after authentication'),
'type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'type of app, 1 = browser, 2 = desktop'),
'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'default access type, bit 1 = read, bit 2 = write'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(

View File

@ -14,8 +14,8 @@ class Oauth_application_user extends Managed_DataObject
public $application_id; // int(4) primary_key not_null
public $access_type; // tinyint(1)
public $token; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime not_null
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -28,8 +28,8 @@ class Oauth_application_user extends Managed_DataObject
'application_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the application'),
'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'access type, bit 1 = read, bit 2 = write'),
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'request or access token'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('profile_id', 'application_id'),
'foreign keys' => array(

View File

@ -13,8 +13,8 @@ class Oauth_token_association extends Managed_DataObject
public $profile_id; // int(4) primary_key not_null
public $application_id; // int(4) primary_key not_null
public $token; // varchar(191) primary key not null not 255 because utf8mb4 takes more space
public $created; // datetime not_null
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -44,8 +44,8 @@ class Oauth_token_association extends Managed_DataObject
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'associated user'),
'application_id' => array('type' => 'int', 'not null' => true, 'description' => 'the application'),
'token' => array('type' => 'varchar', 'length' => '191', 'not null' => true, 'description' => 'token used for this association'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('profile_id', 'application_id', 'token'),
'foreign keys' => array(

View File

@ -72,8 +72,8 @@ class Old_school_prefs extends Managed_DataObject
'size' => 'tiny',
'default' => 1,
'description' => 'Show nicknames for authors and addressees in streams'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('user_id'),
'foreign keys' => array(

View File

@ -36,8 +36,8 @@ class Profile extends Managed_DataObject
public $lon; // decimal(10,7)
public $location_id; // int(4)
public $location_ns; // int(4)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -55,9 +55,8 @@ class Profile extends Managed_DataObject
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'indexes' => array(

View File

@ -33,7 +33,7 @@ class Profile_block extends Managed_DataObject
public $__table = 'profile_block'; // table name
public $blocker; // int(4) primary_key not_null
public $blocked; // int(4) primary_key not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -44,7 +44,7 @@ class Profile_block extends Managed_DataObject
'fields' => array(
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date of blocking'),
),
'foreign keys' => array(
'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')),

View File

@ -31,8 +31,8 @@ class Profile_list extends Managed_DataObject
public $tag; // varchar(64)
public $description; // text
public $private; // tinyint(1)
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
public $mainpage; // varchar(191) not 255 because utf8mb4 takes more space
public $tagged_count; // smallint
@ -48,8 +48,8 @@ class Profile_list extends Managed_DataObject
'description' => array('type' => 'text', 'description' => 'description of the people tag'),
'private' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this tag private'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the tag was added'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the tag was added'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was modified'),
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page to link to'),

View File

@ -34,8 +34,8 @@ class Profile_prefs extends Managed_DataObject
public $namespace; // varchar(191) not_null
public $topic; // varchar(191) not_null
public $data; // text
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -45,8 +45,8 @@ class Profile_prefs extends Managed_DataObject
'namespace' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'namespace, like pluginname or category'),
'topic' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'preference key, i.e. description, age...'),
'data' => array('type' => 'blob', 'description' => 'topic data, may be anything'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('profile_id', 'namespace', 'topic'),
'foreign keys' => array(

View File

@ -35,7 +35,7 @@ class Profile_role extends Managed_DataObject
public $__table = 'profile_role'; // table name
public $profile_id; // int(4) primary_key not_null
public $role; // varchar(32) primary_key not_null
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -46,7 +46,7 @@ class Profile_role extends Managed_DataObject
'fields' => array(
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'account having the role'),
'role' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'string representing the role'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the role was granted'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the role was granted'),
),
'primary key' => array('profile_id', 'role'),
'foreign keys' => array(

View File

@ -9,7 +9,7 @@ class Profile_tag extends Managed_DataObject
public $tagger; // int(4) primary_key not_null
public $tagged; // int(4) primary_key not_null
public $tag; // varchar(64) primary_key not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -19,7 +19,7 @@ class Profile_tag extends Managed_DataObject
'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'),
'tagged' => array('type' => 'int', 'not null' => true, 'description' => 'profile tagged'),
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was added'),
),
'primary key' => array('tagger', 'tagged', 'tag'),
'foreign keys' => array(

View File

@ -12,8 +12,8 @@ class Profile_tag_subscription extends Managed_DataObject
public $__table = 'profile_tag_subscription'; // table name
public $profile_tag_id; // int(4) not_null
public $profile_id; // int(4) not_null
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -25,8 +25,8 @@ class Profile_tag_subscription extends Managed_DataObject
'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'),
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('profile_tag_id', 'profile_id'),
'foreign keys' => array(

View File

@ -13,7 +13,7 @@ class Queue_item extends Managed_DataObject
public $id; // int(4) primary_key not_null
public $frame; // blob not_null
public $transport; // varchar(32)
public $created; // datetime() not_null
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $claimed; // datetime()
/* the code above is auto generated do not remove the tag below */
@ -26,7 +26,7 @@ class Queue_item extends Managed_DataObject
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
'frame' => array('type' => 'blob', 'not null' => true, 'description' => 'data: object reference or opaque string'),
'transport' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'queue for what? "email", "xmpp", "sms", "irc", ...'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'claimed' => array('type' => 'datetime', 'description' => 'date this item was claimed'),
),
'primary key' => array('id'),

View File

@ -11,7 +11,7 @@ class Related_group extends Managed_DataObject
public $__table = 'related_group'; // table name
public $group_id; // int(4) primary_key not_null
public $related_group_id; // int(4) primary_key not_null
public $created; // datetime() not_null
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -23,8 +23,7 @@ class Related_group extends Managed_DataObject
'fields' => array(
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
'related_group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
),
'primary key' => array('group_id', 'related_group_id'),
'foreign keys' => array(

View File

@ -12,7 +12,7 @@ class Remember_me extends Managed_DataObject
public $__table = 'remember_me'; // table name
public $code; // varchar(32) primary_key not_null
public $user_id; // int(4) not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -23,7 +23,7 @@ class Remember_me extends Managed_DataObject
'fields' => array(
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'),
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who is logged in'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('code'),
'foreign keys' => array(

View File

@ -12,7 +12,7 @@ class Reply extends Managed_DataObject
public $__table = 'reply'; // table name
public $notice_id; // int(4) primary_key not_null
public $profile_id; // int(4) primary_key not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public $replied_id; // int(4)
/* the code above is auto generated do not remove the tag below */
@ -24,7 +24,7 @@ class Reply extends Managed_DataObject
'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, 'default' => 'CURRENT_TIMESTAMP', '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'),

View File

@ -11,7 +11,7 @@ class Schema_version extends Managed_DataObject
public $__table = 'schema_version'; // table name
public $table_name; // varchar(64) primary_key not_null
public $checksum; // varchar(64) not_null
public $modified; // datetime() not_null
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -23,7 +23,7 @@ class Schema_version extends Managed_DataObject
'fields' => array(
'table_name' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Table name'),
'checksum' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Checksum of schema array; a mismatch indicates we should check the table more thoroughly.'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('table_name'),
);

View File

@ -45,8 +45,8 @@ class Session extends Managed_DataObject
public $__table = 'session'; // table name
public $id; // varchar(32) primary_key not_null
public $session_data; // text()
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -62,8 +62,8 @@ class Session extends Managed_DataObject
'fields' => [
'id' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'],
'session_data' => ['type' => 'text', 'description' => 'session data'],
'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
],
'primary key' => ['id'],
'indexes' => [

View File

@ -13,8 +13,8 @@ class Sms_carrier extends Managed_DataObject
public $id; // int(4) primary_key not_null
public $name; // varchar(64) unique_key
public $email_pattern; // varchar(191) not_null not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -31,8 +31,8 @@ class Sms_carrier extends Managed_DataObject
'id' => array('type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'),
'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'),
'email_pattern' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(

View File

@ -39,7 +39,7 @@ class Status_network extends Safe_DataObject
public $theme; // varchar(191) not 255 because utf8mb4 takes more space
public $logo; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* Static get */
static function getKV($k,$v=NULL) {

View File

@ -27,7 +27,7 @@ class Status_network_tag extends Safe_DataObject
public $__table = 'status_network_tag'; // table name
public $site_id; // int(4) primary_key not_null
public $tag; // varchar(64) primary_key not_null
public $created; // datetime() not_null
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
function __construct()

View File

@ -35,8 +35,8 @@ class Subscription extends Managed_DataObject
public $token; // varchar(191) not 255 because utf8mb4 takes more space
public $secret; // varchar(191) not 255 because utf8mb4 takes more space
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public static function schemaDef()
{
@ -49,8 +49,8 @@ class Subscription extends Managed_DataObject
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'authorization token'),
'secret' => array('type' => 'varchar', 'length' => 191, 'description' => 'token secret'),
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('subscriber', 'subscribed'),
'unique keys' => array(

View File

@ -20,7 +20,7 @@ class Subscription_queue extends Managed_DataObject
'fields' => array(
'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
'subscribed' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile being subscribed to'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
),
'primary key' => array('subscriber', 'subscribed'),
'indexes' => array(

View File

@ -17,8 +17,8 @@ class Token extends Managed_DataObject
public $state; // tinyint(1)
public $verifier; // varchar(191) not 255 because utf8mb4 takes more space
public $verified_callback; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -34,9 +34,8 @@ class Token extends Managed_DataObject
'state' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'for requests, 0 = initial, 1 = authorized, 2 = used'),
'verifier' => array('type' => 'varchar', 'length' => 191, 'description' => 'verifier string for OAuth 1.0a'),
'verified_callback' => array('type' => 'varchar', 'length' => 191, 'description' => 'verified callback URL for OAuth 1.0a'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('consumer_key', 'tok'),
'foreign keys' => array(

View File

@ -48,7 +48,7 @@ class Unavailable_status_network extends Managed_DataObject
public $__table = 'unavailable_status_network'; // table name
public $nickname; // varchar(64) UUID
public $created; // datetime
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
/**
* The One True Thingy that must be defined and declared.
@ -62,7 +62,7 @@ class Unavailable_status_network extends Managed_DataObject
'length' => 64,
'not null' => true, 'description' => 'nickname not to use'),
'created' => array('type' => 'datetime',
'not null' => true),
'not null' => true, 'default' => '0000-00-00 00:00:00'),
),
'primary key' => array('nickname'),
);

View File

@ -55,8 +55,8 @@ class User extends Managed_DataObject
public $subscribe_policy; // tinyint(1)
public $urlshorteningservice; // varchar(50) default_ur1.ca
public $private_stream; // tinyint(1) default_0
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -89,9 +89,8 @@ class User extends Managed_DataObject
'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'),
'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(

View File

@ -24,8 +24,8 @@ class User_group extends Managed_DataObject
public $homepage_logo; // varchar(191) not 255 because utf8mb4 takes more space
public $stream_logo; // varchar(191) not 255 because utf8mb4 takes more space
public $mini_logo; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
public $mainpage; // varchar(191) not 255 because utf8mb4 takes more space
public $join_policy; // tinyint
@ -58,8 +58,8 @@ class User_group extends Managed_DataObject
'stream_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'),
'mini_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'mini logo'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page for group info to link to'),

View File

@ -41,8 +41,8 @@ class User_im_prefs extends Managed_DataObject
public $notify; // tinyint(1)
public $replies; // tinyint(1)
public $updatefrompresence; // tinyint(1)
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -57,8 +57,8 @@ class User_im_prefs extends Managed_DataObject
'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'),
'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'),
'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to.'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('user_id', 'transport'),
'unique keys' => array(

View File

@ -37,8 +37,8 @@ class User_location_prefs extends Managed_DataObject
public $__table = 'user_location_prefs'; // table name
public $user_id; // int(4) primary_key not_null
public $share_location; // tinyint(1) default_1
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -49,8 +49,8 @@ class User_location_prefs extends Managed_DataObject
'fields' => array(
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'),
'share_location' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Whether to share location data'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('user_id'),
'foreign keys' => array(

View File

@ -31,8 +31,8 @@ class User_urlshortener_prefs extends Managed_DataObject
public $urlshorteningservice; // varchar(50) default_ur1.ca
public $maxurllength; // int(4) not_null
public $maxnoticelength; // int(4) not_null
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -45,9 +45,8 @@ class User_urlshortener_prefs extends Managed_DataObject
'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
'maxurllength' => array('type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, null = never'),
'maxnoticelength' => array('type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, -1 = only if notice text is longer than max allowed'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('user_id'),
'foreign keys' => array(

View File

@ -13,8 +13,8 @@ class User_username extends Managed_DataObject
public $user_id; // int(4) not_null
public $provider_name; // varchar(191) primary_key not_null not 255 because utf8mb4 takes more space
public $username; // varchar(191) primary_key not_null not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@ -26,8 +26,8 @@ class User_username extends Managed_DataObject
'provider_name' => array('type' => 'varchar', 'length' => 191, 'description' => 'provider name'),
'username' => array('type' => 'varchar', 'length' => 191, 'description' => 'username'),
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
),
'primary key' => array('provider_name', 'username'),
'indexes' => array(

View File

@ -55,7 +55,7 @@ abstract class Installer
public static $dbModules = array(
'mysql' => array(
'name' => 'MariaDB (or MySQL 5.5+)',
'name' => 'MariaDB 10.3+',
'check_module' => 'mysqli',
'scheme' => 'mysqli', // DSN prefix for PEAR::DB
),

View File

@ -1,60 +1,51 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
* Database schema for MariaDB
*
* Database schema utilities
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Database
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @category Database
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
/**
* Class representing the database schema
* Class representing the database schema for MariaDB
*
* A class representing the database schema. Can be used to
* manipulate the schema -- especially for plugins and upgrade
* utilities.
*
* @category Database
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class MysqlSchema extends Schema
{
static $_single = null;
protected $conn = null;
/**
* Main public entry point. Use this to get
* the singleton object.
*
* @param null $conn
* @return Schema the (single) Schema object
*/
@ -74,13 +65,14 @@ class MysqlSchema extends Schema
*
* @param string $table Name of the table to get
*
* @return TableDef tabledef for that table.
* @return array of tabledef for that table.
* @throws PEAR_Exception
* @throws SchemaTableMissingException
*/
public function getTableDef($table)
{
$def = array();
$def = [];
$hasKeys = false;
// Pull column data from INFORMATION_SCHEMA
@ -92,7 +84,7 @@ class MysqlSchema extends Schema
foreach ($columns as $row) {
$name = $row['COLUMN_NAME'];
$field = array();
$field = [];
// warning -- 'unsigned' attr on numbers isn't given in DATA_TYPE and friends.
// It is stuck in on COLUMN_TYPE though (eg 'bigint(20) unsigned')
@ -119,7 +111,7 @@ class MysqlSchema extends Schema
if ($row['COLUMN_DEFAULT'] !== null) {
// Hack for timestamp cols
if ($type == 'timestamp' && $row['COLUMN_DEFAULT'] == 'CURRENT_TIMESTAMP') {
// skip
// skip because timestamp is numerical, but it accepts datetime strings as well
} else {
$field['default'] = $row['COLUMN_DEFAULT'];
if ($this->isNumericType($type)) {
@ -144,11 +136,11 @@ class MysqlSchema extends Schema
// ^ ...... how to specify?
}
/* @fixme check against defaults?
if ($row['CHARACTER_SET_NAME'] !== null) {
// @fixme check against defaults?
//$def['charset'] = $row['CHARACTER_SET_NAME'];
//$def['collate'] = $row['COLLATION_NAME'];
}
$def['charset'] = $row['CHARACTER_SET_NAME'];
$def['collate'] = $row['COLLATION_NAME'];
}*/
$def['fields'][$name] = $field;
}
@ -161,13 +153,14 @@ class MysqlSchema extends Schema
// Let's go old school and use SHOW INDEX :D
//
$keyInfo = $this->fetchIndexInfo($table);
$keys = array();
$keys = [];
$keyTypes = [];
foreach ($keyInfo as $row) {
$name = $row['Key_name'];
$column = $row['Column_name'];
if (!isset($keys[$name])) {
$keys[$name] = array();
$keys[$name] = [];
}
$keys[$name][] = $column;
@ -199,8 +192,11 @@ class MysqlSchema extends Schema
* Pull the given table properties from INFORMATION_SCHEMA.
* Most of the good stuff is MySQL extensions.
*
* @param $table
* @param $props
* @return array
* @throws Exception if table info can't be looked up
* @throws PEAR_Exception
* @throws SchemaTableMissingException
*/
function getTableProperties($table, $props)
@ -217,12 +213,15 @@ class MysqlSchema extends Schema
* Pull some INFORMATION.SCHEMA data for the given table.
*
* @param string $table
* @param $infoTable
* @param null $orderBy
* @return array of arrays
* @throws PEAR_Exception
*/
function fetchMetaInfo($table, $infoTable, $orderBy=null)
function fetchMetaInfo($table, $infoTable, $orderBy = null)
{
$query = "SELECT * FROM INFORMATION_SCHEMA.%s " .
"WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='%s'";
"WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='%s'";
$schema = $this->conn->dsn['database'];
$sql = sprintf($query, $infoTable, $schema, $table);
if ($orderBy) {
@ -236,6 +235,7 @@ class MysqlSchema extends Schema
*
* @param string $table
* @return array of arrays
* @throws PEAR_Exception
*/
function fetchIndexInfo($table)
{
@ -284,6 +284,9 @@ class MysqlSchema extends Schema
/**
* Get the unique index key name for a given column on this table
* @param $tableName
* @param $columnName
* @return string
*/
function _uniqueKey($tableName, $columnName)
{
@ -292,6 +295,9 @@ class MysqlSchema extends Schema
/**
* Get the index key name for a given column on this table
* @param $tableName
* @param $columnName
* @return string
*/
function _key($tableName, $columnName)
{
@ -314,7 +320,7 @@ class MysqlSchema extends Schema
* if they were indexes here.
*
* @param array $phrase
* @param <type> $keyName MySQL
* @param string $keyName MySQL
*/
function appendAlterDropUnique(array &$phrase, $keyName)
{
@ -324,13 +330,17 @@ class MysqlSchema extends Schema
/**
* Throw some table metadata onto the ALTER TABLE if we have a mismatch
* in expected type, collation.
* @param array $phrase
* @param $tableName
* @param array $def
* @throws Exception
*/
function appendAlterExtras(array &$phrase, $tableName, array $def)
{
// Check for table properties: make sure we're using a sane
// engine type and charset/collation.
// @fixme make the default engine configurable?
$oldProps = $this->getTableProperties($tableName, array('ENGINE', 'TABLE_COLLATION'));
$oldProps = $this->getTableProperties($tableName, ['ENGINE', 'TABLE_COLLATION']);
$engine = $this->preferredEngine($def);
if (strtolower($oldProps['ENGINE']) != strtolower($engine)) {
$phrase[] = "ENGINE=$engine";
@ -344,10 +354,12 @@ class MysqlSchema extends Schema
/**
* Is this column a string type?
* @param array $cd
* @return bool
*/
private function _isString(array $cd)
{
$strings = array('char', 'varchar', 'text');
$strings = ['char', 'varchar', 'text'];
return in_array(strtolower($cd['type']), $strings);
}
@ -358,14 +370,14 @@ class MysqlSchema extends Schema
* Appropriate for use in CREATE TABLE or
* ALTER TABLE statements.
*
* @param ColumnDef $cd column to create
* @param array $cd column to create
*
* @return string correct SQL for that column
*/
function columnSql(array $cd)
{
$line = array();
$line = [];
$line[] = parent::columnSql($cd);
// This'll have been added from our transform of 'serial' type
@ -383,9 +395,11 @@ class MysqlSchema extends Schema
function mapType($column)
{
$map = array('serial' => 'int',
'integer' => 'int',
'numeric' => 'decimal');
$map = [
'serial' => 'int',
'integer' => 'int',
'numeric' => 'decimal'
];
$type = $column['type'];
if (isset($map[$type])) {
@ -395,10 +409,10 @@ class MysqlSchema extends Schema
if (!empty($column['size'])) {
$size = $column['size'];
if ($type == 'int' &&
in_array($size, array('tiny', 'small', 'medium', 'big'))) {
in_array($size, ['tiny', 'small', 'medium', 'big'])) {
$type = $size . $type;
} else if (in_array($type, array('blob', 'text')) &&
in_array($size, array('tiny', 'medium', 'long'))) {
} else if (in_array($type, ['blob', 'text']) &&
in_array($size, ['tiny', 'medium', 'long'])) {
$type = $size . $type;
}
}
@ -409,7 +423,7 @@ class MysqlSchema extends Schema
function typeAndSize($column)
{
if ($column['type'] == 'enum') {
$vals = array_map(array($this, 'quote'), $column['enum']);
$vals = array_map([$this, 'quote'], $column['enum']);
return 'enum(' . implode(',', $vals) . ')';
} else if ($this->_isString($column)) {
$col = parent::typeAndSize($column);
@ -433,6 +447,7 @@ class MysqlSchema extends Schema
* or type variants that we wouldn't get back from getTableDef().
*
* @param array $tableDef
* @return array
*/
function filterDef(array $tableDef)
{
@ -443,26 +458,6 @@ class MysqlSchema extends Schema
$col['auto_increment'] = true;
}
// Avoid invalid date errors in MySQL 5.7+
if ($col['type'] == 'timestamp' && !isset($col['default'])
&& $version >= 50605) {
$col['default'] = 'CURRENT_TIMESTAMP';
}
if ($col['type'] == 'datetime') {
// Avoid invalid date errors in MySQL 5.7+
if (!isset($col['default']) && $version >= 50605) {
$col['default'] = 'CURRENT_TIMESTAMP';
}
// If we are using MySQL 5.5, convert datetime to timestamp if
// default value is CURRENT_TIMESTAMP. Not needed for MySQL 5.6+
// and MariaDB 10.0+
if (isset($col['default'])
&& $col['default'] == 'CURRENT_TIMESTAMP'
&& $version < 50605) {
$col['type'] = 'timestamp';
}
}
$col['type'] = $this->mapType($col);
unset($col['size']);
}

View File

@ -1,52 +1,43 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
* Database schema for PostgreSQL
*
* Database schema utilities
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Database
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @category Database
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @author Brenda Wallace <shiny@cpan.org>
* @author Brion Vibber <brion@status.net>
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
/**
* Class representing the database schema
* Class representing the database schema for PostgreSQL
*
* A class representing the database schema. Can be used to
* manipulate the schema -- especially for plugins and upgrade
* utilities.
*
* @category Database
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Brenda Wallace <shiny@cpan.org>
* @author Brion Vibber <brion@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class PgsqlSchema extends Schema
{
@ -59,11 +50,12 @@ class PgsqlSchema extends Schema
* @param string $table Name of the table to get
*
* @return array tabledef for that table.
* @throws SchemaTableMissingException
*/
public function getTableDef($table)
{
$def = array();
$def = [];
$hasKeys = false;
// Pull column data from INFORMATION_SCHEMA
@ -73,15 +65,15 @@ class PgsqlSchema extends Schema
}
// We'll need to match up fields by ordinal reference
$orderedFields = array();
$orderedFields = [];
foreach ($columns as $row) {
$name = $row['column_name'];
$orderedFields[$row['ordinal_position']] = $name;
$field = array();
$field['type'] = $row['udt_name'];
$field = [];
$field['type'] = $type = $row['udt_name'];
if ($type == 'char' || $type == 'varchar') {
if ($row['character_maximum_length'] !== null) {
@ -123,7 +115,7 @@ class PgsqlSchema extends Schema
// These are inconvenient arrays with partial references to the
// pg_att table, but since we've already fetched up the column
// info on the current table, we can look those up locally.
$cols = array();
$cols = [];
$colPositions = explode(' ', $row['indkey']);
foreach ($colPositions as $ord) {
if ($ord == 0) {
@ -139,13 +131,13 @@ class PgsqlSchema extends Schema
// Pull constraint data from INFORMATION_SCHEMA:
// Primary key, unique keys, foreign keys
$keyColumns = $this->fetchMetaInfo($table, 'key_column_usage', 'constraint_name,ordinal_position');
$keys = array();
$keys = [];
foreach ($keyColumns as $row) {
$keyName = $row['constraint_name'];
$keyCol = $row['column_name'];
if (!isset($keys[$keyName])) {
$keys[$keyName] = array();
$keys[$keyName] = [];
}
$keys[$keyName][] = $keyCol;
}
@ -157,7 +149,7 @@ class PgsqlSchema extends Schema
} else if (preg_match("/^{$table}_(.*)_fkey$/", $keyName, $matches)) {
$fkey = $this->getForeignKeyInfo($table, $keyName);
$colMap = array_combine($cols, $fkey['col_names']);
$def['foreign keys'][$keyName] = array($fkey['table_name'], $colMap);
$def['foreign keys'][$keyName] = [$fkey['table_name'], $colMap];
} else {
$def['unique keys'][$keyName] = $cols;
}
@ -169,12 +161,15 @@ class PgsqlSchema extends Schema
* Pull some INFORMATION.SCHEMA data for the given table.
*
* @param string $table
* @param $infoTable
* @param null $orderBy
* @return array of arrays
* @throws PEAR_Exception
*/
function fetchMetaInfo($table, $infoTable, $orderBy=null)
function fetchMetaInfo($table, $infoTable, $orderBy = null)
{
$query = "SELECT * FROM information_schema.%s " .
"WHERE table_name='%s'";
"WHERE table_name='%s'";
$sql = sprintf($query, $infoTable, $table);
if ($orderBy) {
$sql .= ' ORDER BY ' . $orderBy;
@ -186,36 +181,39 @@ class PgsqlSchema extends Schema
* Pull some PG-specific index info
* @param string $table
* @return array of arrays
* @throws PEAR_Exception
*/
function getIndexInfo($table)
{
$query = 'SELECT ' .
'(SELECT relname FROM pg_class WHERE oid=indexrelid) AS key_name, ' .
'* FROM pg_index ' .
'WHERE indrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
'AND indisprimary=\'f\' AND indisunique=\'f\' ' .
'ORDER BY indrelid, indexrelid';
'(SELECT relname FROM pg_class WHERE oid=indexrelid) AS key_name, ' .
'* FROM pg_index ' .
'WHERE indrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
'AND indisprimary=\'f\' AND indisunique=\'f\' ' .
'ORDER BY indrelid, indexrelid';
$sql = sprintf($query, $table);
return $this->fetchQueryData($sql);
}
/**
* Column names from the foreign table can be resolved with a call to getTableColumnNames()
* @param <type> $table
* @param string $table
* @param $constraint_name
* @return array array of rows with keys: fkey_name, table_name, table_id, col_names (array of strings)
* @throws PEAR_Exception
*/
function getForeignKeyInfo($table, $constraint_name)
{
// In a sane world, it'd be easier to query the column names directly.
// But it's pretty hard to work with arrays such as col_indexes in direct SQL here.
$query = 'SELECT ' .
'(SELECT relname FROM pg_class WHERE oid=confrelid) AS table_name, ' .
'confrelid AS table_id, ' .
'(SELECT indkey FROM pg_index WHERE indexrelid=conindid) AS col_indexes ' .
'FROM pg_constraint ' .
'WHERE conrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
'AND conname=\'%s\' ' .
'AND contype=\'f\'';
'(SELECT relname FROM pg_class WHERE oid=confrelid) AS table_name, ' .
'confrelid AS table_id, ' .
'(SELECT indkey FROM pg_index WHERE indexrelid=conindid) AS col_indexes ' .
'FROM pg_constraint ' .
'WHERE conrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
'AND conname=\'%s\' ' .
'AND contype=\'f\'';
$sql = sprintf($query, $table, $constraint_name);
$data = $this->fetchQueryData($sql);
if (count($data) < 1) {
@ -223,10 +221,10 @@ class PgsqlSchema extends Schema
}
$row = $data[0];
return array(
return [
'table_name' => $row['table_name'],
'col_names' => $this->getTableColumnNames($row['table_id'], $row['col_indexes'])
);
];
}
/**
@ -234,22 +232,23 @@ class PgsqlSchema extends Schema
* @param int $table_id
* @param array $col_indexes
* @return array of strings
* @throws PEAR_Exception
*/
function getTableColumnNames($table_id, $col_indexes)
{
$indexes = array_map('intval', explode(' ', $col_indexes));
$query = 'SELECT attnum AS col_index, attname AS col_name ' .
'FROM pg_attribute where attrelid=%d ' .
'AND attnum IN (%s)';
'FROM pg_attribute where attrelid=%d ' .
'AND attnum IN (%s)';
$sql = sprintf($query, $table_id, implode(',', $indexes));
$data = $this->fetchQueryData($sql);
$byId = array();
$byId = [];
foreach ($data as $row) {
$byId[$row['col_index']] = $row['col_name'];
}
$out = array();
$out = [];
foreach ($indexes as $id) {
$out[] = $byId[$id];
}
@ -262,14 +261,15 @@ class PgsqlSchema extends Schema
*
* @return string postgres happy column type
*/
private function _columnTypeTranslation($type) {
$map = array(
'datetime' => 'timestamp',
);
if(!empty($map[$type])) {
return $map[$type];
}
return $type;
private function _columnTypeTranslation($type)
{
$map = [
'datetime' => 'timestamp',
];
if (!empty($map[$type])) {
return $map[$type];
}
return $type;
}
/**
@ -286,7 +286,7 @@ class PgsqlSchema extends Schema
function columnSql(array $cd)
{
$line = array();
$line = [];
$line[] = parent::columnSql($cd);
/*
@ -341,7 +341,6 @@ class PgsqlSchema extends Schema
* @param array $statements
* @param string $table
* @param string $name
* @param array $def
*/
function appendDropIndex(array &$statements, $table, $name)
{
@ -361,10 +360,12 @@ class PgsqlSchema extends Schema
function mapType($column)
{
$map = array('serial' => 'bigserial', // FIXME: creates the wrong name for the sequence for some internal sequence-lookup function, so better fix this to do the real 'create sequence' dance.
'numeric' => 'decimal',
'datetime' => 'timestamp',
'blob' => 'bytea');
$map = [
'serial' => 'bigserial', // FIXME: creates the wrong name for the sequence for some internal sequence-lookup function, so better fix this to do the real 'create sequence' dance.
'numeric' => 'decimal',
'datetime' => 'timestamp',
'blob' => 'bytea'
];
$type = $column['type'];
if (isset($map[$type])) {
@ -390,7 +391,7 @@ class PgsqlSchema extends Schema
function typeAndSize($column)
{
if ($column['type'] == 'enum') {
$vals = array_map(array($this, 'quote'), $column['enum']);
$vals = array_map([$this, 'quote'], $column['enum']);
return "text check ($name in " . implode(',', $vals) . ')';
} else {
return parent::typeAndSize($column);
@ -405,6 +406,7 @@ class PgsqlSchema extends Schema
* or type variants that we wouldn't get back from getTableDef().
*
* @param array $tableDef
* @return array
*/
function filterDef(array $tableDef)
{
@ -444,8 +446,7 @@ class PgsqlSchema extends Schema
function filterKeyDef(array $def)
{
// PostgreSQL doesn't like prefix lengths specified on keys...?
foreach ($def as $i => $item)
{
foreach ($def as $i => $item) {
if (is_array($item)) {
$def[$i] = $item[0];
}

View File

@ -1,35 +1,31 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
* Database schema
*
* Database schema utilities
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Database
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @category Database
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @author Brion Vibber <brion@status.net>
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
/**
* Class representing the database schema
@ -38,14 +34,9 @@ if (!defined('STATUSNET')) {
* manipulate the schema -- especially for plugins and upgrade
* utilities.
*
* @category Database
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Brion Vibber <brion@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class Schema
{
static $_static = null;
@ -53,6 +44,7 @@ class Schema
/**
* Constructor. Only run once for singleton object.
* @param null $conn
*/
protected function __construct($conn = null)
@ -72,6 +64,7 @@ class Schema
* Main public entry point. Use this to get
* the schema object.
*
* @param null $conn
* @return Schema the Schema object for the connection
*/
@ -82,10 +75,10 @@ class Schema
} else {
$key = md5(serialize($conn->dsn));
}
$type = common_config('db', 'type');
if (empty(self::$_static[$key])) {
$schemaClass = ucfirst($type).'Schema';
$schemaClass = ucfirst($type) . 'Schema';
self::$_static[$key] = new $schemaClass($conn);
}
return self::$_static[$key];
@ -96,7 +89,7 @@ class Schema
*
* Throws an exception if the table is not found.
*
* @param string $table name of the table
* @param string $table name of the table
* @param string $column name of the column
*
* @return ColumnDef definition of the column or null
@ -121,10 +114,11 @@ class Schema
/**
* Creates a table with the given names and columns.
*
* @param string $tableName Name of the table
* @param array $def Table definition array listing fields and indexes.
* @param string $tableName Name of the table
* @param array $def Table definition array listing fields and indexes.
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function createTable($tableName, $def)
@ -137,16 +131,17 @@ class Schema
* Build a set of SQL statements to create a table with the given
* name and columns.
*
* @param string $name Name of the table
* @param array $def Table definition array
* @param string $name Name of the table
* @param array $def Table definition array
*
* @return boolean success flag
* @return array success flag
* @throws Exception
*/
public function buildCreateTable($name, $def)
{
$def = $this->validateDef($name, $def);
$def = $this->filterDef($def);
$sql = array();
$sql = [];
foreach ($def['fields'] as $col => $colDef) {
$this->appendColumnDef($sql, $col, $colDef);
@ -171,10 +166,10 @@ class Schema
}
// Wrap the CREATE TABLE around the main body chunks...
$statements = array();
$statements = [];
$statements[] = $this->startCreateTable($name, $def) . "\n" .
implode($sql, ",\n") . "\n" .
$this->endCreateTable($name, $def);
implode($sql, ",\n") . "\n" .
$this->endCreateTable($name, $def);
// Multi-value indexes are advisory and for best portability
// should be created as separate statements.
@ -197,11 +192,11 @@ class Schema
*
* @param string $name table name
* @param array $def table definition
* @param $string
* @return string
*/
function startCreateTable($name, array $def)
{
return 'CREATE TABLE ' . $this->quoteIdentifier($name) . ' (';
return 'CREATE TABLE ' . $this->quoteIdentifier($name) . ' (';
}
/**
@ -260,6 +255,7 @@ class Schema
* @param array $sql
* @param string $name
* @param array $def
* @throws Exception
*/
function appendForeignKeyDef(array &$sql, $name, array $def)
{
@ -270,11 +266,11 @@ class Schema
$srcCols = array_keys($map);
$refCols = array_values($map);
$sql[] = "CONSTRAINT $name FOREIGN KEY " .
$this->buildIndexList($srcCols) .
" REFERENCES " .
$this->quoteIdentifier($refTable) .
" " .
$this->buildIndexList($refCols);
$this->buildIndexList($srcCols) .
" REFERENCES " .
$this->quoteIdentifier($refTable) .
" " .
$this->buildIndexList($refCols);
}
/**
@ -299,6 +295,7 @@ class Schema
* @param string $table
* @param string $name
* @param array $def
* @throws Exception
*/
function appendCreateFulltextIndex(array &$statements, $table, $name, array $def)
{
@ -311,7 +308,6 @@ class Schema
* @param array $statements
* @param string $table
* @param string $name
* @param array $def
*/
function appendDropIndex(array &$statements, $table, $name)
{
@ -321,7 +317,7 @@ class Schema
function buildIndexList(array $def)
{
// @fixme
return '(' . implode(',', array_map(array($this, 'buildIndexItem'), $def)) . ')';
return '(' . implode(',', array_map([$this, 'buildIndexItem'], $def)) . ')';
}
function buildIndexItem($def)
@ -340,7 +336,8 @@ class Schema
*
* @param string $name Name of the table to drop
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function dropTable($name)
@ -365,28 +362,29 @@ class Schema
* Throws an exception on database error, esp. if the table
* does not exist.
*
* @param string $table Name of the table
* @param array $columnNames Name of columns to index
* @param string $name (Optional) name of the index
* @param string $table Name of the table
* @param array $columnNames Name of columns to index
* @param string $name (Optional) name of the index
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function createIndex($table, $columnNames, $name=null)
public function createIndex($table, $columnNames, $name = null)
{
global $_PEAR;
if (!is_array($columnNames)) {
$columnNames = array($columnNames);
$columnNames = [$columnNames];
}
if (empty($name)) {
$name = "{$table}_".implode("_", $columnNames)."_idx";
$name = "{$table}_" . implode("_", $columnNames) . "_idx";
}
$res = $this->conn->query("ALTER TABLE $table ".
"ADD INDEX $name (".
implode(",", $columnNames).")");
$res = $this->conn->query("ALTER TABLE $table " .
"ADD INDEX $name (" .
implode(",", $columnNames) . ")");
if ($_PEAR->isError($res)) {
PEAR_ErrorToPEAR_Exception($res);
@ -399,9 +397,10 @@ class Schema
* Drops a named index from a table.
*
* @param string $table name of the table the index is on.
* @param string $name name of the index
* @param string $name name of the index
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function dropIndex($table, $name)
@ -420,11 +419,12 @@ class Schema
/**
* Adds a column to a table
*
* @param string $table name of the table
* @param string $table name of the table
* @param ColumnDef $columndef Definition of the new
* column.
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function addColumn($table, $columndef)
@ -447,10 +447,11 @@ class Schema
*
* The name must match an existing column and table.
*
* @param string $table name of the table
* @param string $table name of the table
* @param ColumnDef $columndef new definition of the column.
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function modifyColumn($table, $columndef)
@ -458,7 +459,7 @@ class Schema
global $_PEAR;
$sql = "ALTER TABLE $table MODIFY COLUMN " .
$this->_columnSql($columndef);
$this->_columnSql($columndef);
$res = $this->conn->query($sql);
@ -474,10 +475,11 @@ class Schema
*
* The name must match an existing column.
*
* @param string $table name of the table
* @param string $table name of the table
* @param string $columnName name of the column to drop
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function dropColumn($table, $columnName)
@ -504,9 +506,10 @@ class Schema
* alter the table to match the column definitions.
*
* @param string $tableName name of the table
* @param array $def Table definition array
* @param array $def Table definition array
*
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
public function ensureTable($tableName, $def)
@ -521,7 +524,8 @@ class Schema
*
* @fixme if multiple statements, wrap in a transaction?
* @param array $statements
* @return boolean success flag
* @return bool success flag
* @throws PEAR_Exception
*/
function runSqlSet(array $statements)
{
@ -530,12 +534,12 @@ class Schema
$ok = true;
foreach ($statements as $sql) {
if (defined('DEBUG_INSTALLER')) {
echo "<tt>" . htmlspecialchars($sql) . "</tt><br/>\n";
echo "<code>" . htmlspecialchars($sql) . "</code><br/>\n";
}
$res = $this->conn->query($sql);
if ($_PEAR->isError($res)) {
common_debug('PEAR exception on query: '.$sql);
common_debug('PEAR exception on query: ' . $sql);
PEAR_ErrorToPEAR_Exception($res);
}
}
@ -553,10 +557,9 @@ class Schema
* match the column definitions.
*
* @param string $tableName name of the table
* @param array $columns array of ColumnDef
* objects for the table
*
* @param array $def
* @return array of SQL statements
* @throws Exception
*/
function buildEnsureTable($tableName, array $def)
@ -572,8 +575,8 @@ class Schema
$def = $this->validateDef($tableName, $def);
$def = $this->filterDef($def);
$statements = array();
$fields = $this->diffArrays($old, $def, 'fields', array($this, 'columnsEqual'));
$statements = [];
$fields = $this->diffArrays($old, $def, 'fields', [$this, 'columnsEqual']);
$uniques = $this->diffArrays($old, $def, 'unique keys');
$indexes = $this->diffArrays($old, $def, 'indexes');
$foreign = $this->diffArrays($old, $def, 'foreign keys');
@ -592,7 +595,7 @@ class Schema
// For efficiency, we want this all in one
// query, instead of using our methods.
$phrase = array();
$phrase = [];
foreach ($foreign['del'] + $foreign['mod'] as $keyName) {
$this->appendAlterDropForeign($phrase, $keyName);
@ -608,13 +611,13 @@ class Schema
foreach ($fields['add'] as $columnName) {
$this->appendAlterAddColumn($phrase, $columnName,
$def['fields'][$columnName]);
$def['fields'][$columnName]);
}
foreach ($fields['mod'] as $columnName) {
$this->appendAlterModifyColumn($phrase, $columnName,
$old['fields'][$columnName],
$def['fields'][$columnName]);
$old['fields'][$columnName],
$def['fields'][$columnName]);
}
foreach ($fields['del'] as $columnName) {
@ -653,19 +656,19 @@ class Schema
return $statements;
}
function diffArrays($oldDef, $newDef, $section, $compareCallback=null)
function diffArrays($oldDef, $newDef, $section, $compareCallback = null)
{
$old = isset($oldDef[$section]) ? $oldDef[$section] : array();
$new = isset($newDef[$section]) ? $newDef[$section] : array();
$old = isset($oldDef[$section]) ? $oldDef[$section] : [];
$new = isset($newDef[$section]) ? $newDef[$section] : [];
$oldKeys = array_keys($old);
$newKeys = array_keys($new);
$toadd = array_diff($newKeys, $oldKeys);
$toadd = array_diff($newKeys, $oldKeys);
$todrop = array_diff($oldKeys, $newKeys);
$same = array_intersect($newKeys, $oldKeys);
$tomod = array();
$tokeep = array();
$same = array_intersect($newKeys, $oldKeys);
$tomod = [];
$tokeep = [];
// Find which fields have actually changed definition
// in a way that we need to tweak them for this DB type.
@ -681,11 +684,13 @@ class Schema
}
$tomod[] = $name;
}
return array('add' => $toadd,
'del' => $todrop,
'mod' => $tomod,
'keep' => $tokeep,
'count' => count($toadd) + count($todrop) + count($tomod));
return [
'add' => $toadd,
'del' => $todrop,
'mod' => $tomod,
'keep' => $tokeep,
'count' => count($toadd) + count($todrop) + count($tomod)
];
}
/**
@ -694,14 +699,14 @@ class Schema
*
* @param array $phrase
* @param string $columnName
* @param array $cd
* @param array $cd
*/
function appendAlterAddColumn(array &$phrase, $columnName, array $cd)
{
$phrase[] = 'ADD COLUMN ' .
$this->quoteIdentifier($columnName) .
' ' .
$this->columnSql($cd);
$this->quoteIdentifier($columnName) .
' ' .
$this->columnSql($cd);
}
/**
@ -716,9 +721,9 @@ class Schema
function appendAlterModifyColumn(array &$phrase, $columnName, array $old, array $cd)
{
$phrase[] = 'MODIFY COLUMN ' .
$this->quoteIdentifier($columnName) .
' ' .
$this->columnSql($cd);
$this->quoteIdentifier($columnName) .
' ' .
$this->columnSql($cd);
}
/**
@ -735,7 +740,7 @@ class Schema
function appendAlterAddUnique(array &$phrase, $keyName, array $def)
{
$sql = array();
$sql = [];
$sql[] = 'ADD';
$this->appendUniqueKeyDef($sql, $keyName, $def);
$phrase[] = implode(' ', $sql);
@ -743,7 +748,7 @@ class Schema
function appendAlterAddForeign(array &$phrase, $keyName, array $def)
{
$sql = array();
$sql = [];
$sql[] = 'ADD';
$this->appendForeignKeyDef($sql, $keyName, $def);
$phrase[] = implode(' ', $sql);
@ -751,7 +756,7 @@ class Schema
function appendAlterAddPrimary(array &$phrase, array $def)
{
$sql = array();
$sql = [];
$sql[] = 'ADD';
$this->appendPrimaryKeyDef($sql, $def);
$phrase[] = implode(' ', $sql);
@ -809,7 +814,7 @@ class Schema
*
* @param array $a
* @param array $b
* @return boolean
* @return bool
*/
function columnsEqual(array $a, array $b)
{
@ -827,7 +832,7 @@ class Schema
protected function _names($cds)
{
$names = array();
$names = [];
foreach ($cds as $cd) {
$names[] = $cd->name;
@ -840,7 +845,7 @@ class Schema
* Get a ColumnDef from an array matching
* name.
*
* @param array $cds Array of ColumnDef objects
* @param array $cds Array of ColumnDef objects
* @param string $name Name of the column
*
* @return ColumnDef matching item or null if no match.
@ -864,14 +869,14 @@ class Schema
* Appropriate for use in CREATE TABLE or
* ALTER TABLE statements.
*
* @param ColumnDef $cd column to create
* @param array $cd column to create
*
* @return string correct SQL for that column
*/
function columnSql(array $cd)
{
$line = array();
$line = [];
$line[] = $this->typeAndSize($cd);
if (isset($cd['default'])) {
@ -902,7 +907,7 @@ class Schema
if (isset($column['size'])) {
$type = $column['size'] . $type;
}
$lengths = array();
$lengths = [];
if (isset($column['precision'])) {
$lengths[] = $column['precision'];
@ -926,20 +931,20 @@ class Schema
* with plugins written for 0.9.x.
*
* @param string $tableName
* @param array $defs: array of ColumnDef objects
* @param array $defs : array of ColumnDef objects
* @return array
*/
protected function oldToNew($tableName, array $defs)
{
$table = array();
$prefixes = array(
$table = [];
$prefixes = [
'tiny',
'small',
'medium',
'big',
);
];
foreach ($defs as $cd) {
$column = array();
$column = [];
$column['type'] = $cd->type;
foreach ($prefixes as $prefix) {
if (substr($cd->type, 0, strlen($prefix)) == $prefix) {
@ -969,19 +974,19 @@ class Schema
// If multiple columns are defined as primary key,
// we'll pile them on in sequence.
if (!isset($table['primary key'])) {
$table['primary key'] = array();
$table['primary key'] = [];
}
$table['primary key'][] = $cd->name;
} else if ($cd->key == 'MUL') {
// Individual multiple-value indexes are only per-column
// using the old ColumnDef syntax.
$idx = "{$tableName}_{$cd->name}_idx";
$table['indexes'][$idx] = array($cd->name);
$table['indexes'][$idx] = [$cd->name];
} else if ($cd->key == 'UNI') {
// Individual unique-value indexes are only per-column
// using the old ColumnDef syntax.
$idx = "{$tableName}_{$cd->name}_idx";
$table['unique keys'][$idx] = array($cd->name);
$table['unique keys'][$idx] = [$cd->name];
}
}
@ -996,6 +1001,7 @@ class Schema
* or type variants that we wouldn't get back from getTableDef().
*
* @param array $tableDef
* @return array
*/
function filterDef(array $tableDef)
{
@ -1008,7 +1014,7 @@ class Schema
* If necessary, converts from an old-style array of ColumnDef objects.
*
* @param string $tableName
* @param array $def: table definition array
* @param array $def : table definition array
* @return array validated table definition array
*
* @throws Exception on wildly invalid input
@ -1030,7 +1036,7 @@ class Schema
function isNumericType($type)
{
$type = strtolower($type);
$known = array('int', 'serial', 'numeric');
$known = ['int', 'serial', 'numeric'];
return in_array($type, $known);
}
@ -1039,6 +1045,7 @@ class Schema
*
* @param string $sql
* @return array of arrays
* @throws PEAR_Exception
*/
protected function fetchQueryData($sql)
{
@ -1049,8 +1056,8 @@ class Schema
PEAR_ErrorToPEAR_Exception($res);
}
$out = array();
$row = array();
$out = [];
$row = [];
while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
$out[] = $row;
}