[CORE] Bump Database requirement to MariaDB 10.3+
This commit is contained in:
parent
7044f0e2cf
commit
f67a93eddc
@ -23,8 +23,8 @@ class Attention extends Managed_DataObject
|
|||||||
public $notice_id; // int(4) primary_key not_null
|
public $notice_id; // int(4) primary_key not_null
|
||||||
public $profile_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 $reason; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
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'),
|
'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'),
|
'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'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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', 'profile_id'),
|
'primary key' => array('notice_id', 'profile_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -15,8 +15,8 @@ class Avatar extends Managed_DataObject
|
|||||||
public $height; // int(4) primary_key not_null
|
public $height; // int(4) primary_key not_null
|
||||||
public $mediatype; // varchar(32) not_null
|
public $mediatype; // varchar(32) not_null
|
||||||
public $filename; // varchar(191) not 255 because utf8mb4 takes more space
|
public $filename; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
@ -28,8 +28,8 @@ class Avatar extends Managed_DataObject
|
|||||||
'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'),
|
'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'),
|
||||||
'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'),
|
'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'),
|
||||||
'filename' => array('type' => 'varchar', 'length' => 191, 'description' => 'local filename, if local'),
|
'filename' => array('type' => 'varchar', 'length' => 191, 'description' => 'local filename, if local'),
|
||||||
'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'),
|
||||||
'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('profile_id', 'width', 'height'),
|
'primary key' => array('profile_id', 'width', 'height'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -13,7 +13,7 @@ class Confirm_address extends Managed_DataObject
|
|||||||
public $address_type; // varchar(8) not_null
|
public $address_type; // varchar(8) not_null
|
||||||
public $claimed; // datetime()
|
public $claimed; // datetime()
|
||||||
public $sent; // datetime()
|
public $sent; // datetime()
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
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")'),
|
'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
|
||||||
'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'),
|
'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'),
|
||||||
'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'),
|
'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('code'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -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_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 $consumer_secret; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||||
public $seed; // char(32) not_null
|
public $seed; // char(32) not_null
|
||||||
public $created; // datetime not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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_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'),
|
'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'),
|
'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('consumer_key'),
|
'primary key' => array('consumer_key'),
|
||||||
);
|
);
|
||||||
|
@ -37,8 +37,8 @@ class Conversation extends Managed_DataObject
|
|||||||
public $id; // int(4) primary_key not_null auto_increment
|
public $id; // int(4) primary_key not_null auto_increment
|
||||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
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 $url; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
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'),
|
'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'),
|
'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)'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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'),
|
'primary key' => array('id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -46,7 +46,7 @@ class File extends Managed_DataObject
|
|||||||
public $filename; // text()
|
public $filename; // text()
|
||||||
public $width; // int(4)
|
public $width; // int(4)
|
||||||
public $height; // 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 URLHASH_ALG = 'sha256';
|
||||||
const FILEHASH_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'),
|
'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'),
|
'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'),
|
'height' => array('type' => 'int', 'description' => 'height in pixels, if it can be described as such and data is available'),
|
||||||
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('id'),
|
'primary key' => array('id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -34,7 +34,7 @@ class File_redirection extends Managed_DataObject
|
|||||||
public $file_id; // int(4)
|
public $file_id; // int(4)
|
||||||
public $redirections; // int(4)
|
public $redirections; // int(4)
|
||||||
public $httpcode; // 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -50,7 +50,7 @@ class File_redirection extends Managed_DataObject
|
|||||||
'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'),
|
'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'),
|
||||||
'redirections' => array('type' => 'int', 'description' => 'redirect count'),
|
'redirections' => array('type' => 'int', 'description' => 'redirect count'),
|
||||||
'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'),
|
'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('urlhash'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -32,7 +32,7 @@ class File_thumbnail extends Managed_DataObject
|
|||||||
public $filename; // text
|
public $filename; // text
|
||||||
public $width; // int(4) primary_key
|
public $width; // int(4) primary_key
|
||||||
public $height; // 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';
|
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'),
|
'filename' => array('type' => 'text', 'description' => 'if stored locally, filename is put here'),
|
||||||
'width' => array('type' => 'int', 'description' => 'width of thumbnail'),
|
'width' => array('type' => 'int', 'description' => 'width of thumbnail'),
|
||||||
'height' => array('type' => 'int', 'description' => 'height of thumbnail'),
|
'height' => array('type' => 'int', 'description' => 'height of thumbnail'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('file_id', 'width', 'height'),
|
||||||
'indexes' => array(
|
'indexes' => array(
|
||||||
|
@ -31,7 +31,7 @@ class File_to_post extends Managed_DataObject
|
|||||||
public $__table = 'file_to_post'; // table name
|
public $__table = 'file_to_post'; // table name
|
||||||
public $file_id; // int(4) primary_key not_null
|
public $file_id; // int(4) primary_key not_null
|
||||||
public $post_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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -42,7 +42,7 @@ class File_to_post extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'),
|
'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'),
|
||||||
'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'),
|
'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('file_id', 'post_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -19,8 +19,8 @@ class Foreign_link extends Managed_DataObject
|
|||||||
public $profilesync; // tinyint(1) not_null default_1
|
public $profilesync; // tinyint(1) not_null default_1
|
||||||
public $last_noticesync; // datetime()
|
public $last_noticesync; // datetime()
|
||||||
public $last_friendsync; // datetime()
|
public $last_friendsync; // datetime()
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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_noticesync' => array('type' => 'datetime', 'description' => 'last time notices were imported'),
|
||||||
'last_friendsync' => array('type' => 'datetime', 'description' => 'last time friends were imported'),
|
'last_friendsync' => array('type' => 'datetime', 'description' => 'last time friends were imported'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('user_id', 'foreign_id', 'service'),
|
'primary key' => array('user_id', 'foreign_id', 'service'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -13,8 +13,8 @@ class Foreign_service extends Managed_DataObject
|
|||||||
public $id; // int(4) primary_key not_null
|
public $id; // int(4) primary_key not_null
|
||||||
public $name; // varchar(32) unique_key not_null
|
public $name; // varchar(32) unique_key not_null
|
||||||
public $description; // varchar(191) not 255 because utf8mb4 takes more space
|
public $description; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -26,8 +26,8 @@ class Foreign_service extends Managed_DataObject
|
|||||||
'id' => array('type' => 'int', 'not null' => true, 'description' => 'numeric key for service'),
|
'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'),
|
'name' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'),
|
||||||
'description' => array('type' => 'varchar', 'length' => 191, 'description' => 'description'),
|
'description' => array('type' => 'varchar', 'length' => 191, 'description' => 'description'),
|
||||||
'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'),
|
||||||
'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'),
|
'primary key' => array('id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -13,7 +13,7 @@ class Foreign_subscription extends Managed_DataObject
|
|||||||
public $service; // int(4) primary_key not_null
|
public $service; // int(4) primary_key not_null
|
||||||
public $subscriber; // int(4) primary_key not_null
|
public $subscriber; // int(4) primary_key not_null
|
||||||
public $subscribed; // 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -26,7 +26,7 @@ class Foreign_subscription extends Managed_DataObject
|
|||||||
'service' => array('type' => 'int', 'not null' => true, 'description' => 'service where relationship happens'),
|
'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'),
|
'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'),
|
'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'),
|
'primary key' => array('service', 'subscriber', 'subscribed'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -14,8 +14,8 @@ class Foreign_user extends Managed_DataObject
|
|||||||
public $service; // int(4) primary_key not_null
|
public $service; // int(4) primary_key not_null
|
||||||
public $uri; // varchar(191) unique_key not_null not 255 because utf8mb4 takes more space
|
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 $nickname; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -28,8 +28,8 @@ class Foreign_user extends Managed_DataObject
|
|||||||
'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
|
'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
|
||||||
'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'),
|
||||||
'nickname' => array('type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'),
|
'nickname' => array('type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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', 'service'),
|
'primary key' => array('id', 'service'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -31,7 +31,7 @@ class Group_alias extends Managed_DataObject
|
|||||||
public $__table = 'group_alias'; // table name
|
public $__table = 'group_alias'; // table name
|
||||||
public $alias; // varchar(64) primary_key not_null
|
public $alias; // varchar(64) primary_key not_null
|
||||||
public $group_id; // int(4) 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -42,7 +42,7 @@ class Group_alias extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'),
|
'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'),
|
||||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
|
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('alias'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -32,7 +32,7 @@ class Group_block extends Managed_DataObject
|
|||||||
public $group_id; // int(4) primary_key not_null
|
public $group_id; // int(4) primary_key not_null
|
||||||
public $blocked; // int(4) primary_key not_null
|
public $blocked; // int(4) primary_key not_null
|
||||||
public $blocker; // int(4) 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
|
||||||
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
|
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
|
||||||
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
|
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('group_id', 'blocked'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -11,7 +11,7 @@ class Group_inbox extends Managed_DataObject
|
|||||||
public $__table = 'group_inbox'; // table name
|
public $__table = 'group_inbox'; // table name
|
||||||
public $group_id; // int(4) primary_key not_null
|
public $group_id; // int(4) primary_key not_null
|
||||||
public $notice_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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -23,7 +23,7 @@ class Group_inbox extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group receiving the message'),
|
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group receiving the message'),
|
||||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'),
|
'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'),
|
'primary key' => array('group_id', 'notice_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -24,7 +24,7 @@ class Group_join_queue extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
|
'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'),
|
'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'),
|
'primary key' => array('profile_id', 'group_id'),
|
||||||
'indexes' => array(
|
'indexes' => array(
|
||||||
|
@ -13,8 +13,8 @@ class Group_member extends Managed_DataObject
|
|||||||
public $profile_id; // int(4) primary_key not_null
|
public $profile_id; // int(4) primary_key not_null
|
||||||
public $is_admin; // tinyint(1)
|
public $is_admin; // tinyint(1)
|
||||||
public $uri; // 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 $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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?'),
|
'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'),
|
||||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
||||||
'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'),
|
||||||
'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('group_id', 'profile_id'),
|
'primary key' => array('group_id', 'profile_id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -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; // varchar(191) multiple_key not_null not 255 because utf8mb4 takes more space
|
||||||
public $address_type; // varchar(8) multiple_key not_null
|
public $address_type; // varchar(8) multiple_key not_null
|
||||||
public $registered_user_id; // int(4) 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -36,7 +36,7 @@ class Invitation extends Managed_DataObject
|
|||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'),
|
'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' => 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")'),
|
'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'),
|
'registered_user_id' => array('type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'),
|
||||||
),
|
),
|
||||||
'primary key' => array('code'),
|
'primary key' => array('code'),
|
||||||
|
@ -11,8 +11,8 @@ class Local_group extends Managed_DataObject
|
|||||||
public $__table = 'local_group'; // table name
|
public $__table = 'local_group'; // table name
|
||||||
public $group_id; // int(4) primary_key not_null
|
public $group_id; // int(4) primary_key not_null
|
||||||
public $nickname; // varchar(64) unique_key
|
public $nickname; // varchar(64) unique_key
|
||||||
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -24,9 +24,8 @@ class Local_group extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'),
|
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'),
|
||||||
'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'),
|
'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('group_id'),
|
'primary key' => array('group_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -33,8 +33,8 @@ class Location_namespace extends Managed_DataObject
|
|||||||
public $__table = 'location_namespace'; // table name
|
public $__table = 'location_namespace'; // table name
|
||||||
public $id; // int(4) primary_key not_null
|
public $id; // int(4) primary_key not_null
|
||||||
public $description; // varchar(191)
|
public $description; // varchar(191)
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -45,8 +45,8 @@ class Location_namespace extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'),
|
'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'),
|
||||||
'description' => array('type' => 'varchar', 'length' => 191, 'description' => 'description of the 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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the record was created'),
|
||||||
'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'),
|
'primary key' => array('id'),
|
||||||
);
|
);
|
||||||
|
@ -31,8 +31,8 @@ class Login_token extends Managed_DataObject
|
|||||||
public $__table = 'login_token'; // table name
|
public $__table = 'login_token'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $token; // char(32) not_null
|
public $token; // char(32) not_null
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -43,8 +43,8 @@ class Login_token extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'),
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'),
|
||||||
'token' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'token useable for logging in'),
|
'token' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'token useable for logging in'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('user_id'),
|
'primary key' => array('user_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -14,8 +14,8 @@ class Nonce extends Managed_DataObject
|
|||||||
public $tok; // char(32)
|
public $tok; // char(32)
|
||||||
public $nonce; // char(32) primary_key not_null
|
public $nonce; // char(32) primary_key not_null
|
||||||
public $ts; // datetime() primary_key not_null
|
public $ts; // datetime() primary_key not_null
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -43,9 +43,8 @@ class Nonce extends Managed_DataObject
|
|||||||
'tok' => array('type' => 'char', 'length' => 32, 'description' => 'buggy old value, ignored'),
|
'tok' => array('type' => 'char', 'length' => 32, 'description' => 'buggy old value, ignored'),
|
||||||
'nonce' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'nonce'),
|
'nonce' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'nonce'),
|
||||||
'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'),
|
'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('consumer_key', 'ts', 'nonce'),
|
'primary key' => array('consumer_key', 'ts', 'nonce'),
|
||||||
);
|
);
|
||||||
|
@ -59,8 +59,8 @@ class Notice extends Managed_DataObject
|
|||||||
public $content; // text
|
public $content; // text
|
||||||
public $rendered; // text
|
public $rendered; // text
|
||||||
public $url; // varchar(191) not 255 because utf8mb4 takes more space
|
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 $created; // datetime() multiple_key not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
public $reply_to; // int(4)
|
public $reply_to; // int(4)
|
||||||
public $is_local; // int(4)
|
public $is_local; // int(4)
|
||||||
public $source; // varchar(32)
|
public $source; // varchar(32)
|
||||||
@ -83,8 +83,8 @@ class Notice extends Managed_DataObject
|
|||||||
'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8mb4_general_ci'),
|
'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8mb4_general_ci'),
|
||||||
'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
|
'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
|
||||||
'url' => array('type' => 'varchar', 'length' => 191, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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'),
|
||||||
'reply_to' => array('type' => 'int', 'description' => 'notice replied to (usually a guess)'),
|
'reply_to' => array('type' => 'int', 'description' => 'notice replied to (usually a guess)'),
|
||||||
'is_local' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'notice was generated by a user'),
|
'is_local' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'notice was generated by a user'),
|
||||||
'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'),
|
'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'),
|
||||||
|
@ -11,7 +11,7 @@ class Notice_location extends Managed_DataObject
|
|||||||
public $lon; // decimal(10,7)
|
public $lon; // decimal(10,7)
|
||||||
public $location_id; // int(4)
|
public $location_id; // int(4)
|
||||||
public $location_ns; // 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()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ class Notice_location extends Managed_DataObject
|
|||||||
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
|
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
|
||||||
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
|
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
|
||||||
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
|
'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'),
|
'primary key' => array('notice_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -34,8 +34,8 @@ class Notice_prefs extends Managed_DataObject
|
|||||||
public $namespace; // varchar(191) not_null
|
public $namespace; // varchar(191) not_null
|
||||||
public $topic; // varchar(191) not_null
|
public $topic; // varchar(191) not_null
|
||||||
public $data; // text
|
public $data; // text
|
||||||
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
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'),
|
'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...'),
|
'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'),
|
'data' => array('type' => 'blob', 'description' => 'topic data, may be anything'),
|
||||||
'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'),
|
||||||
'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', 'namespace', 'topic'),
|
'primary key' => array('notice_id', 'namespace', 'topic'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -13,8 +13,8 @@ class Notice_source extends Managed_DataObject
|
|||||||
public $code; // varchar(32) primary_key not_null
|
public $code; // varchar(32) primary_key not_null
|
||||||
public $name; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
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 $url; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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'),
|
'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'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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'),
|
'primary key' => array('code'),
|
||||||
);
|
);
|
||||||
|
@ -27,7 +27,7 @@ class Notice_tag extends Managed_DataObject
|
|||||||
public $__table = 'notice_tag'; // table name
|
public $__table = 'notice_tag'; // table name
|
||||||
public $tag; // varchar(64) primary_key not_null
|
public $tag; // varchar(64) primary_key not_null
|
||||||
public $notice_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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -39,7 +39,7 @@ class Notice_tag extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
|
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
|
||||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice tagged'),
|
'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'),
|
'primary key' => array('tag', 'notice_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -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 $callback_url; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||||
public $type; // tinyint(1)
|
public $type; // tinyint(1)
|
||||||
public $access_type; // tinyint(1)
|
public $access_type; // tinyint(1)
|
||||||
public $created; // datetime not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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'),
|
'type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'type of app, 1 = browser, 2 = desktop'),
|
||||||
'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'default access type, bit 1 = read, bit 2 = write'),
|
'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'default access type, bit 1 = read, bit 2 = write'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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'),
|
'primary key' => array('id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -14,8 +14,8 @@ class Oauth_application_user extends Managed_DataObject
|
|||||||
public $application_id; // int(4) primary_key not_null
|
public $application_id; // int(4) primary_key not_null
|
||||||
public $access_type; // tinyint(1)
|
public $access_type; // tinyint(1)
|
||||||
public $token; // varchar(191) not 255 because utf8mb4 takes more space
|
public $token; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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'),
|
'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'),
|
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'request or access token'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('profile_id', 'application_id'),
|
'primary key' => array('profile_id', 'application_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -13,8 +13,8 @@ class Oauth_token_association extends Managed_DataObject
|
|||||||
public $profile_id; // int(4) primary_key not_null
|
public $profile_id; // int(4) primary_key not_null
|
||||||
public $application_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 $token; // varchar(191) primary key not null not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -44,8 +44,8 @@ class Oauth_token_association extends Managed_DataObject
|
|||||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'associated user'),
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'associated user'),
|
||||||
'application_id' => array('type' => 'int', 'not null' => true, 'description' => 'the application'),
|
'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'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('profile_id', 'application_id', 'token'),
|
'primary key' => array('profile_id', 'application_id', 'token'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -72,8 +72,8 @@ class Old_school_prefs extends Managed_DataObject
|
|||||||
'size' => 'tiny',
|
'size' => 'tiny',
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
'description' => 'Show nicknames for authors and addressees in streams'),
|
'description' => 'Show nicknames for authors and addressees in streams'),
|
||||||
'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'),
|
||||||
'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('user_id'),
|
'primary key' => array('user_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -36,8 +36,8 @@ class Profile extends Managed_DataObject
|
|||||||
public $lon; // decimal(10,7)
|
public $lon; // decimal(10,7)
|
||||||
public $location_id; // int(4)
|
public $location_id; // int(4)
|
||||||
public $location_ns; // int(4)
|
public $location_ns; // int(4)
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
@ -55,9 +55,8 @@ class Profile extends Managed_DataObject
|
|||||||
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
|
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
|
||||||
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
|
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
|
||||||
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
|
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('id'),
|
'primary key' => array('id'),
|
||||||
'indexes' => array(
|
'indexes' => array(
|
||||||
|
@ -33,7 +33,7 @@ class Profile_block extends Managed_DataObject
|
|||||||
public $__table = 'profile_block'; // table name
|
public $__table = 'profile_block'; // table name
|
||||||
public $blocker; // int(4) primary_key not_null
|
public $blocker; // int(4) primary_key not_null
|
||||||
public $blocked; // 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -44,7 +44,7 @@ class Profile_block extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
|
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
|
||||||
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
|
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date of blocking'),
|
||||||
),
|
),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')),
|
'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')),
|
||||||
|
@ -31,8 +31,8 @@ class Profile_list extends Managed_DataObject
|
|||||||
public $tag; // varchar(64)
|
public $tag; // varchar(64)
|
||||||
public $description; // text
|
public $description; // text
|
||||||
public $private; // tinyint(1)
|
public $private; // tinyint(1)
|
||||||
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
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 $mainpage; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $tagged_count; // smallint
|
public $tagged_count; // smallint
|
||||||
@ -48,8 +48,8 @@ class Profile_list extends Managed_DataObject
|
|||||||
'description' => array('type' => 'text', 'description' => 'description of the people tag'),
|
'description' => array('type' => 'text', 'description' => 'description of the people tag'),
|
||||||
'private' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this tag private'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the tag was added'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'),
|
'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'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
||||||
'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page to link to'),
|
'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page to link to'),
|
||||||
|
@ -34,8 +34,8 @@ class Profile_prefs extends Managed_DataObject
|
|||||||
public $namespace; // varchar(191) not_null
|
public $namespace; // varchar(191) not_null
|
||||||
public $topic; // varchar(191) not_null
|
public $topic; // varchar(191) not_null
|
||||||
public $data; // text
|
public $data; // text
|
||||||
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
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'),
|
'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...'),
|
'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'),
|
'data' => array('type' => 'blob', 'description' => 'topic data, may be anything'),
|
||||||
'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'),
|
||||||
'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('profile_id', 'namespace', 'topic'),
|
'primary key' => array('profile_id', 'namespace', 'topic'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -35,7 +35,7 @@ class Profile_role extends Managed_DataObject
|
|||||||
public $__table = 'profile_role'; // table name
|
public $__table = 'profile_role'; // table name
|
||||||
public $profile_id; // int(4) primary_key not_null
|
public $profile_id; // int(4) primary_key not_null
|
||||||
public $role; // varchar(32) 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -46,7 +46,7 @@ class Profile_role extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'account having the role'),
|
'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'),
|
'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'),
|
'primary key' => array('profile_id', 'role'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -9,7 +9,7 @@ class Profile_tag extends Managed_DataObject
|
|||||||
public $tagger; // int(4) primary_key not_null
|
public $tagger; // int(4) primary_key not_null
|
||||||
public $tagged; // int(4) primary_key not_null
|
public $tagged; // int(4) primary_key not_null
|
||||||
public $tag; // varchar(64) 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()
|
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'),
|
'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'),
|
||||||
'tagged' => array('type' => 'int', 'not null' => true, 'description' => 'profile tagged'),
|
'tagged' => array('type' => 'int', 'not null' => true, 'description' => 'profile tagged'),
|
||||||
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
|
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('tagger', 'tagged', 'tag'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -12,8 +12,8 @@ class Profile_tag_subscription extends Managed_DataObject
|
|||||||
public $__table = 'profile_tag_subscription'; // table name
|
public $__table = 'profile_tag_subscription'; // table name
|
||||||
public $profile_tag_id; // int(4) not_null
|
public $profile_tag_id; // int(4) not_null
|
||||||
public $profile_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 $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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_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'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('profile_tag_id', 'profile_id'),
|
'primary key' => array('profile_tag_id', 'profile_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -13,7 +13,7 @@ class Queue_item extends Managed_DataObject
|
|||||||
public $id; // int(4) primary_key not_null
|
public $id; // int(4) primary_key not_null
|
||||||
public $frame; // blob not_null
|
public $frame; // blob not_null
|
||||||
public $transport; // varchar(32)
|
public $transport; // varchar(32)
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $claimed; // datetime()
|
public $claimed; // datetime()
|
||||||
|
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* 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'),
|
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
|
||||||
'frame' => array('type' => 'blob', 'not null' => true, 'description' => 'data: object reference or opaque string'),
|
'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", ...'),
|
'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'),
|
'claimed' => array('type' => 'datetime', 'description' => 'date this item was claimed'),
|
||||||
),
|
),
|
||||||
'primary key' => array('id'),
|
'primary key' => array('id'),
|
||||||
|
@ -11,7 +11,7 @@ class Related_group extends Managed_DataObject
|
|||||||
public $__table = 'related_group'; // table name
|
public $__table = 'related_group'; // table name
|
||||||
public $group_id; // int(4) primary_key not_null
|
public $group_id; // int(4) primary_key not_null
|
||||||
public $related_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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -23,8 +23,7 @@ class Related_group extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
|
'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'),
|
'related_group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('group_id', 'related_group_id'),
|
'primary key' => array('group_id', 'related_group_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -12,7 +12,7 @@ class Remember_me extends Managed_DataObject
|
|||||||
public $__table = 'remember_me'; // table name
|
public $__table = 'remember_me'; // table name
|
||||||
public $code; // varchar(32) primary_key not_null
|
public $code; // varchar(32) primary_key not_null
|
||||||
public $user_id; // int(4) 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -23,7 +23,7 @@ class Remember_me extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'),
|
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'),
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who is logged in'),
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who is logged in'),
|
||||||
'modified' => array('type' => 'timestamp', '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'),
|
'primary key' => array('code'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -12,7 +12,7 @@ class Reply extends Managed_DataObject
|
|||||||
public $__table = 'reply'; // table name
|
public $__table = 'reply'; // table name
|
||||||
public $notice_id; // int(4) primary_key not_null
|
public $notice_id; // int(4) primary_key not_null
|
||||||
public $profile_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)
|
public $replied_id; // int(4)
|
||||||
|
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
@ -24,7 +24,7 @@ class Reply extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'),
|
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'),
|
||||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile replied to'),
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile replied to'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'),
|
'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'),
|
||||||
),
|
),
|
||||||
'primary key' => array('notice_id', 'profile_id'),
|
'primary key' => array('notice_id', 'profile_id'),
|
||||||
|
@ -11,7 +11,7 @@ class Schema_version extends Managed_DataObject
|
|||||||
public $__table = 'schema_version'; // table name
|
public $__table = 'schema_version'; // table name
|
||||||
public $table_name; // varchar(64) primary_key not_null
|
public $table_name; // varchar(64) primary_key not_null
|
||||||
public $checksum; // varchar(64) 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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -23,7 +23,7 @@ class Schema_version extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'table_name' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Table name'),
|
'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.'),
|
'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'),
|
'primary key' => array('table_name'),
|
||||||
);
|
);
|
||||||
|
@ -45,8 +45,8 @@ class Session extends Managed_DataObject
|
|||||||
public $__table = 'session'; // table name
|
public $__table = 'session'; // table name
|
||||||
public $id; // varchar(32) primary_key not_null
|
public $id; // varchar(32) primary_key not_null
|
||||||
public $session_data; // text()
|
public $session_data; // text()
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -62,8 +62,8 @@ class Session extends Managed_DataObject
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'id' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'],
|
'id' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'],
|
||||||
'session_data' => ['type' => 'text', 'description' => 'session data'],
|
'session_data' => ['type' => 'text', 'description' => 'session data'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
'indexes' => [
|
'indexes' => [
|
||||||
|
@ -13,8 +13,8 @@ class Sms_carrier extends Managed_DataObject
|
|||||||
public $id; // int(4) primary_key not_null
|
public $id; // int(4) primary_key not_null
|
||||||
public $name; // varchar(64) unique_key
|
public $name; // varchar(64) unique_key
|
||||||
public $email_pattern; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
public $email_pattern; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'id' => array('type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'),
|
||||||
'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'),
|
'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'),
|
||||||
'email_pattern' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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'),
|
'primary key' => array('id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -39,7 +39,7 @@ class Status_network extends Safe_DataObject
|
|||||||
public $theme; // varchar(191) not 255 because utf8mb4 takes more space
|
public $theme; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $logo; // 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 $created; // datetime() not_null
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/* Static get */
|
/* Static get */
|
||||||
static function getKV($k,$v=NULL) {
|
static function getKV($k,$v=NULL) {
|
||||||
|
@ -27,7 +27,7 @@ class Status_network_tag extends Safe_DataObject
|
|||||||
public $__table = 'status_network_tag'; // table name
|
public $__table = 'status_network_tag'; // table name
|
||||||
public $site_id; // int(4) primary_key not_null
|
public $site_id; // int(4) primary_key not_null
|
||||||
public $tag; // varchar(64) 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()
|
function __construct()
|
||||||
|
@ -35,8 +35,8 @@ class Subscription extends Managed_DataObject
|
|||||||
public $token; // varchar(191) not 255 because utf8mb4 takes more space
|
public $token; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $secret; // 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 $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
@ -49,8 +49,8 @@ class Subscription extends Managed_DataObject
|
|||||||
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'authorization token'),
|
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'authorization token'),
|
||||||
'secret' => array('type' => 'varchar', 'length' => 191, 'description' => 'token secret'),
|
'secret' => array('type' => 'varchar', 'length' => 191, 'description' => 'token secret'),
|
||||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier'),
|
||||||
'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'),
|
||||||
'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('subscriber', 'subscribed'),
|
'primary key' => array('subscriber', 'subscribed'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -20,7 +20,7 @@ class Subscription_queue extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
|
'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'),
|
'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'),
|
'primary key' => array('subscriber', 'subscribed'),
|
||||||
'indexes' => array(
|
'indexes' => array(
|
||||||
|
@ -17,8 +17,8 @@ class Token extends Managed_DataObject
|
|||||||
public $state; // tinyint(1)
|
public $state; // tinyint(1)
|
||||||
public $verifier; // varchar(191) not 255 because utf8mb4 takes more space
|
public $verifier; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $verified_callback; // 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 $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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'),
|
'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'),
|
'verified_callback' => array('type' => 'varchar', 'length' => 191, 'description' => 'verified callback URL for OAuth 1.0a'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('consumer_key', 'tok'),
|
'primary key' => array('consumer_key', 'tok'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -48,7 +48,7 @@ class Unavailable_status_network extends Managed_DataObject
|
|||||||
public $__table = 'unavailable_status_network'; // table name
|
public $__table = 'unavailable_status_network'; // table name
|
||||||
|
|
||||||
public $nickname; // varchar(64) UUID
|
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.
|
* The One True Thingy that must be defined and declared.
|
||||||
@ -62,7 +62,7 @@ class Unavailable_status_network extends Managed_DataObject
|
|||||||
'length' => 64,
|
'length' => 64,
|
||||||
'not null' => true, 'description' => 'nickname not to use'),
|
'not null' => true, 'description' => 'nickname not to use'),
|
||||||
'created' => array('type' => 'datetime',
|
'created' => array('type' => 'datetime',
|
||||||
'not null' => true),
|
'not null' => true, 'default' => '0000-00-00 00:00:00'),
|
||||||
),
|
),
|
||||||
'primary key' => array('nickname'),
|
'primary key' => array('nickname'),
|
||||||
);
|
);
|
||||||
|
@ -55,8 +55,8 @@ class User extends Managed_DataObject
|
|||||||
public $subscribe_policy; // tinyint(1)
|
public $subscribe_policy; // tinyint(1)
|
||||||
public $urlshorteningservice; // varchar(50) default_ur1.ca
|
public $urlshorteningservice; // varchar(50) default_ur1.ca
|
||||||
public $private_stream; // tinyint(1) default_0
|
public $private_stream; // tinyint(1) default_0
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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'),
|
'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'),
|
'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, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('id'),
|
'primary key' => array('id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -24,8 +24,8 @@ class User_group extends Managed_DataObject
|
|||||||
public $homepage_logo; // varchar(191) not 255 because utf8mb4 takes more space
|
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 $stream_logo; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $mini_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 $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
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 $mainpage; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $join_policy; // tinyint
|
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'),
|
'stream_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'),
|
||||||
'mini_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'mini logo'),
|
'mini_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'mini logo'),
|
||||||
|
|
||||||
'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'),
|
||||||
'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'),
|
||||||
|
|
||||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
||||||
'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page for group info to link to'),
|
'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page for group info to link to'),
|
||||||
|
@ -41,8 +41,8 @@ class User_im_prefs extends Managed_DataObject
|
|||||||
public $notify; // tinyint(1)
|
public $notify; // tinyint(1)
|
||||||
public $replies; // tinyint(1)
|
public $replies; // tinyint(1)
|
||||||
public $updatefrompresence; // tinyint(1)
|
public $updatefrompresence; // tinyint(1)
|
||||||
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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'),
|
'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.'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('user_id', 'transport'),
|
'primary key' => array('user_id', 'transport'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -37,8 +37,8 @@ class User_location_prefs extends Managed_DataObject
|
|||||||
public $__table = 'user_location_prefs'; // table name
|
public $__table = 'user_location_prefs'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $share_location; // tinyint(1) default_1
|
public $share_location; // tinyint(1) default_1
|
||||||
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -49,8 +49,8 @@ class User_location_prefs extends Managed_DataObject
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'),
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'),
|
||||||
'share_location' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Whether to share location data'),
|
'share_location' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Whether to share location data'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('user_id'),
|
'primary key' => array('user_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -31,8 +31,8 @@ class User_urlshortener_prefs extends Managed_DataObject
|
|||||||
public $urlshorteningservice; // varchar(50) default_ur1.ca
|
public $urlshorteningservice; // varchar(50) default_ur1.ca
|
||||||
public $maxurllength; // int(4) not_null
|
public $maxurllength; // int(4) not_null
|
||||||
public $maxnoticelength; // int(4) not_null
|
public $maxnoticelength; // int(4) 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
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###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'),
|
'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'),
|
'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'),
|
'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, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
||||||
),
|
),
|
||||||
'primary key' => array('user_id'),
|
'primary key' => array('user_id'),
|
||||||
'foreign keys' => array(
|
'foreign keys' => array(
|
||||||
|
@ -13,8 +13,8 @@ class User_username extends Managed_DataObject
|
|||||||
public $user_id; // int(4) not_null
|
public $user_id; // int(4) not_null
|
||||||
public $provider_name; // varchar(191) primary_key not_null not 255 because utf8mb4 takes more space
|
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 $username; // varchar(191) primary_key not_null not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
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 */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
@ -26,8 +26,8 @@ class User_username extends Managed_DataObject
|
|||||||
'provider_name' => array('type' => 'varchar', 'length' => 191, 'description' => 'provider name'),
|
'provider_name' => array('type' => 'varchar', 'length' => 191, 'description' => 'provider name'),
|
||||||
'username' => array('type' => 'varchar', 'length' => 191, 'description' => 'username'),
|
'username' => array('type' => 'varchar', 'length' => 191, 'description' => 'username'),
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
|
'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'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'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('provider_name', 'username'),
|
'primary key' => array('provider_name', 'username'),
|
||||||
'indexes' => array(
|
'indexes' => array(
|
||||||
|
@ -55,7 +55,7 @@ abstract class Installer
|
|||||||
|
|
||||||
public static $dbModules = array(
|
public static $dbModules = array(
|
||||||
'mysql' => array(
|
'mysql' => array(
|
||||||
'name' => 'MariaDB (or MySQL 5.5+)',
|
'name' => 'MariaDB 10.3+',
|
||||||
'check_module' => 'mysqli',
|
'check_module' => 'mysqli',
|
||||||
'scheme' => 'mysqli', // DSN prefix for PEAR::DB
|
'scheme' => 'mysqli', // DSN prefix for PEAR::DB
|
||||||
),
|
),
|
||||||
|
@ -1,60 +1,51 @@
|
|||||||
<?php
|
<?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
|
* @category Database
|
||||||
*
|
* @package GNUsocial
|
||||||
* PHP version 5
|
* @author Evan Prodromou <evan@status.net>
|
||||||
*
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* 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/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing the database schema
|
* Class representing the database schema for MariaDB
|
||||||
*
|
*
|
||||||
* A class representing the database schema. Can be used to
|
* A class representing the database schema. Can be used to
|
||||||
* manipulate the schema -- especially for plugins and upgrade
|
* manipulate the schema -- especially for plugins and upgrade
|
||||||
* utilities.
|
* utilities.
|
||||||
*
|
*
|
||||||
* @category Database
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @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/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MysqlSchema extends Schema
|
class MysqlSchema extends Schema
|
||||||
{
|
{
|
||||||
static $_single = null;
|
static $_single = null;
|
||||||
protected $conn = null;
|
protected $conn = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main public entry point. Use this to get
|
* Main public entry point. Use this to get
|
||||||
* the singleton object.
|
* the singleton object.
|
||||||
*
|
*
|
||||||
|
* @param null $conn
|
||||||
* @return Schema the (single) Schema object
|
* @return Schema the (single) Schema object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -74,13 +65,14 @@ class MysqlSchema extends Schema
|
|||||||
*
|
*
|
||||||
* @param string $table Name of the table to get
|
* @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
|
* @throws SchemaTableMissingException
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function getTableDef($table)
|
public function getTableDef($table)
|
||||||
{
|
{
|
||||||
$def = array();
|
$def = [];
|
||||||
$hasKeys = false;
|
$hasKeys = false;
|
||||||
|
|
||||||
// Pull column data from INFORMATION_SCHEMA
|
// Pull column data from INFORMATION_SCHEMA
|
||||||
@ -92,7 +84,7 @@ class MysqlSchema extends Schema
|
|||||||
foreach ($columns as $row) {
|
foreach ($columns as $row) {
|
||||||
|
|
||||||
$name = $row['COLUMN_NAME'];
|
$name = $row['COLUMN_NAME'];
|
||||||
$field = array();
|
$field = [];
|
||||||
|
|
||||||
// warning -- 'unsigned' attr on numbers isn't given in DATA_TYPE and friends.
|
// 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')
|
// 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) {
|
if ($row['COLUMN_DEFAULT'] !== null) {
|
||||||
// Hack for timestamp cols
|
// Hack for timestamp cols
|
||||||
if ($type == 'timestamp' && $row['COLUMN_DEFAULT'] == 'CURRENT_TIMESTAMP') {
|
if ($type == 'timestamp' && $row['COLUMN_DEFAULT'] == 'CURRENT_TIMESTAMP') {
|
||||||
// skip
|
// skip because timestamp is numerical, but it accepts datetime strings as well
|
||||||
} else {
|
} else {
|
||||||
$field['default'] = $row['COLUMN_DEFAULT'];
|
$field['default'] = $row['COLUMN_DEFAULT'];
|
||||||
if ($this->isNumericType($type)) {
|
if ($this->isNumericType($type)) {
|
||||||
@ -144,11 +136,11 @@ class MysqlSchema extends Schema
|
|||||||
// ^ ...... how to specify?
|
// ^ ...... how to specify?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* @fixme check against defaults?
|
||||||
if ($row['CHARACTER_SET_NAME'] !== null) {
|
if ($row['CHARACTER_SET_NAME'] !== null) {
|
||||||
// @fixme check against defaults?
|
$def['charset'] = $row['CHARACTER_SET_NAME'];
|
||||||
//$def['charset'] = $row['CHARACTER_SET_NAME'];
|
$def['collate'] = $row['COLLATION_NAME'];
|
||||||
//$def['collate'] = $row['COLLATION_NAME'];
|
}*/
|
||||||
}
|
|
||||||
|
|
||||||
$def['fields'][$name] = $field;
|
$def['fields'][$name] = $field;
|
||||||
}
|
}
|
||||||
@ -161,13 +153,14 @@ class MysqlSchema extends Schema
|
|||||||
// Let's go old school and use SHOW INDEX :D
|
// Let's go old school and use SHOW INDEX :D
|
||||||
//
|
//
|
||||||
$keyInfo = $this->fetchIndexInfo($table);
|
$keyInfo = $this->fetchIndexInfo($table);
|
||||||
$keys = array();
|
$keys = [];
|
||||||
|
$keyTypes = [];
|
||||||
foreach ($keyInfo as $row) {
|
foreach ($keyInfo as $row) {
|
||||||
$name = $row['Key_name'];
|
$name = $row['Key_name'];
|
||||||
$column = $row['Column_name'];
|
$column = $row['Column_name'];
|
||||||
|
|
||||||
if (!isset($keys[$name])) {
|
if (!isset($keys[$name])) {
|
||||||
$keys[$name] = array();
|
$keys[$name] = [];
|
||||||
}
|
}
|
||||||
$keys[$name][] = $column;
|
$keys[$name][] = $column;
|
||||||
|
|
||||||
@ -199,8 +192,11 @@ class MysqlSchema extends Schema
|
|||||||
* Pull the given table properties from INFORMATION_SCHEMA.
|
* Pull the given table properties from INFORMATION_SCHEMA.
|
||||||
* Most of the good stuff is MySQL extensions.
|
* Most of the good stuff is MySQL extensions.
|
||||||
*
|
*
|
||||||
|
* @param $table
|
||||||
|
* @param $props
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception if table info can't be looked up
|
* @throws PEAR_Exception
|
||||||
|
* @throws SchemaTableMissingException
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getTableProperties($table, $props)
|
function getTableProperties($table, $props)
|
||||||
@ -217,12 +213,15 @@ class MysqlSchema extends Schema
|
|||||||
* Pull some INFORMATION.SCHEMA data for the given table.
|
* Pull some INFORMATION.SCHEMA data for the given table.
|
||||||
*
|
*
|
||||||
* @param string $table
|
* @param string $table
|
||||||
|
* @param $infoTable
|
||||||
|
* @param null $orderBy
|
||||||
* @return array of arrays
|
* @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 " .
|
$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'];
|
$schema = $this->conn->dsn['database'];
|
||||||
$sql = sprintf($query, $infoTable, $schema, $table);
|
$sql = sprintf($query, $infoTable, $schema, $table);
|
||||||
if ($orderBy) {
|
if ($orderBy) {
|
||||||
@ -236,6 +235,7 @@ class MysqlSchema extends Schema
|
|||||||
*
|
*
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array of arrays
|
* @return array of arrays
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
function fetchIndexInfo($table)
|
function fetchIndexInfo($table)
|
||||||
{
|
{
|
||||||
@ -284,6 +284,9 @@ class MysqlSchema extends Schema
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the unique index key name for a given column on this table
|
* Get the unique index key name for a given column on this table
|
||||||
|
* @param $tableName
|
||||||
|
* @param $columnName
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _uniqueKey($tableName, $columnName)
|
function _uniqueKey($tableName, $columnName)
|
||||||
{
|
{
|
||||||
@ -292,6 +295,9 @@ class MysqlSchema extends Schema
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the index key name for a given column on this table
|
* Get the index key name for a given column on this table
|
||||||
|
* @param $tableName
|
||||||
|
* @param $columnName
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _key($tableName, $columnName)
|
function _key($tableName, $columnName)
|
||||||
{
|
{
|
||||||
@ -314,7 +320,7 @@ class MysqlSchema extends Schema
|
|||||||
* if they were indexes here.
|
* if they were indexes here.
|
||||||
*
|
*
|
||||||
* @param array $phrase
|
* @param array $phrase
|
||||||
* @param <type> $keyName MySQL
|
* @param string $keyName MySQL
|
||||||
*/
|
*/
|
||||||
function appendAlterDropUnique(array &$phrase, $keyName)
|
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
|
* Throw some table metadata onto the ALTER TABLE if we have a mismatch
|
||||||
* in expected type, collation.
|
* in expected type, collation.
|
||||||
|
* @param array $phrase
|
||||||
|
* @param $tableName
|
||||||
|
* @param array $def
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function appendAlterExtras(array &$phrase, $tableName, array $def)
|
function appendAlterExtras(array &$phrase, $tableName, array $def)
|
||||||
{
|
{
|
||||||
// Check for table properties: make sure we're using a sane
|
// Check for table properties: make sure we're using a sane
|
||||||
// engine type and charset/collation.
|
// engine type and charset/collation.
|
||||||
// @fixme make the default engine configurable?
|
// @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);
|
$engine = $this->preferredEngine($def);
|
||||||
if (strtolower($oldProps['ENGINE']) != strtolower($engine)) {
|
if (strtolower($oldProps['ENGINE']) != strtolower($engine)) {
|
||||||
$phrase[] = "ENGINE=$engine";
|
$phrase[] = "ENGINE=$engine";
|
||||||
@ -344,10 +354,12 @@ class MysqlSchema extends Schema
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this column a string type?
|
* Is this column a string type?
|
||||||
|
* @param array $cd
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function _isString(array $cd)
|
private function _isString(array $cd)
|
||||||
{
|
{
|
||||||
$strings = array('char', 'varchar', 'text');
|
$strings = ['char', 'varchar', 'text'];
|
||||||
return in_array(strtolower($cd['type']), $strings);
|
return in_array(strtolower($cd['type']), $strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,14 +370,14 @@ class MysqlSchema extends Schema
|
|||||||
* Appropriate for use in CREATE TABLE or
|
* Appropriate for use in CREATE TABLE or
|
||||||
* ALTER TABLE statements.
|
* ALTER TABLE statements.
|
||||||
*
|
*
|
||||||
* @param ColumnDef $cd column to create
|
* @param array $cd column to create
|
||||||
*
|
*
|
||||||
* @return string correct SQL for that column
|
* @return string correct SQL for that column
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function columnSql(array $cd)
|
function columnSql(array $cd)
|
||||||
{
|
{
|
||||||
$line = array();
|
$line = [];
|
||||||
$line[] = parent::columnSql($cd);
|
$line[] = parent::columnSql($cd);
|
||||||
|
|
||||||
// This'll have been added from our transform of 'serial' type
|
// This'll have been added from our transform of 'serial' type
|
||||||
@ -383,9 +395,11 @@ class MysqlSchema extends Schema
|
|||||||
|
|
||||||
function mapType($column)
|
function mapType($column)
|
||||||
{
|
{
|
||||||
$map = array('serial' => 'int',
|
$map = [
|
||||||
'integer' => 'int',
|
'serial' => 'int',
|
||||||
'numeric' => 'decimal');
|
'integer' => 'int',
|
||||||
|
'numeric' => 'decimal'
|
||||||
|
];
|
||||||
|
|
||||||
$type = $column['type'];
|
$type = $column['type'];
|
||||||
if (isset($map[$type])) {
|
if (isset($map[$type])) {
|
||||||
@ -395,10 +409,10 @@ class MysqlSchema extends Schema
|
|||||||
if (!empty($column['size'])) {
|
if (!empty($column['size'])) {
|
||||||
$size = $column['size'];
|
$size = $column['size'];
|
||||||
if ($type == 'int' &&
|
if ($type == 'int' &&
|
||||||
in_array($size, array('tiny', 'small', 'medium', 'big'))) {
|
in_array($size, ['tiny', 'small', 'medium', 'big'])) {
|
||||||
$type = $size . $type;
|
$type = $size . $type;
|
||||||
} else if (in_array($type, array('blob', 'text')) &&
|
} else if (in_array($type, ['blob', 'text']) &&
|
||||||
in_array($size, array('tiny', 'medium', 'long'))) {
|
in_array($size, ['tiny', 'medium', 'long'])) {
|
||||||
$type = $size . $type;
|
$type = $size . $type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,7 +423,7 @@ class MysqlSchema extends Schema
|
|||||||
function typeAndSize($column)
|
function typeAndSize($column)
|
||||||
{
|
{
|
||||||
if ($column['type'] == 'enum') {
|
if ($column['type'] == 'enum') {
|
||||||
$vals = array_map(array($this, 'quote'), $column['enum']);
|
$vals = array_map([$this, 'quote'], $column['enum']);
|
||||||
return 'enum(' . implode(',', $vals) . ')';
|
return 'enum(' . implode(',', $vals) . ')';
|
||||||
} else if ($this->_isString($column)) {
|
} else if ($this->_isString($column)) {
|
||||||
$col = parent::typeAndSize($column);
|
$col = parent::typeAndSize($column);
|
||||||
@ -433,6 +447,7 @@ class MysqlSchema extends Schema
|
|||||||
* or type variants that we wouldn't get back from getTableDef().
|
* or type variants that we wouldn't get back from getTableDef().
|
||||||
*
|
*
|
||||||
* @param array $tableDef
|
* @param array $tableDef
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function filterDef(array $tableDef)
|
function filterDef(array $tableDef)
|
||||||
{
|
{
|
||||||
@ -443,26 +458,6 @@ class MysqlSchema extends Schema
|
|||||||
$col['auto_increment'] = true;
|
$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);
|
$col['type'] = $this->mapType($col);
|
||||||
unset($col['size']);
|
unset($col['size']);
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,43 @@
|
|||||||
<?php
|
<?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
|
* @category Database
|
||||||
*
|
* @package GNUsocial
|
||||||
* PHP version 5
|
* @author Evan Prodromou <evan@status.net>
|
||||||
*
|
* @author Brenda Wallace <shiny@cpan.org>
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
* @author Brion Vibber <brion@status.net>
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* (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/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing the database schema
|
* Class representing the database schema for PostgreSQL
|
||||||
*
|
*
|
||||||
* A class representing the database schema. Can be used to
|
* A class representing the database schema. Can be used to
|
||||||
* manipulate the schema -- especially for plugins and upgrade
|
* manipulate the schema -- especially for plugins and upgrade
|
||||||
* utilities.
|
* utilities.
|
||||||
*
|
*
|
||||||
* @category Database
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @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/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PgsqlSchema extends Schema
|
class PgsqlSchema extends Schema
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -59,11 +50,12 @@ class PgsqlSchema extends Schema
|
|||||||
* @param string $table Name of the table to get
|
* @param string $table Name of the table to get
|
||||||
*
|
*
|
||||||
* @return array tabledef for that table.
|
* @return array tabledef for that table.
|
||||||
|
* @throws SchemaTableMissingException
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function getTableDef($table)
|
public function getTableDef($table)
|
||||||
{
|
{
|
||||||
$def = array();
|
$def = [];
|
||||||
$hasKeys = false;
|
$hasKeys = false;
|
||||||
|
|
||||||
// Pull column data from INFORMATION_SCHEMA
|
// Pull column data from INFORMATION_SCHEMA
|
||||||
@ -73,15 +65,15 @@ class PgsqlSchema extends Schema
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We'll need to match up fields by ordinal reference
|
// We'll need to match up fields by ordinal reference
|
||||||
$orderedFields = array();
|
$orderedFields = [];
|
||||||
|
|
||||||
foreach ($columns as $row) {
|
foreach ($columns as $row) {
|
||||||
|
|
||||||
$name = $row['column_name'];
|
$name = $row['column_name'];
|
||||||
$orderedFields[$row['ordinal_position']] = $name;
|
$orderedFields[$row['ordinal_position']] = $name;
|
||||||
|
|
||||||
$field = array();
|
$field = [];
|
||||||
$field['type'] = $row['udt_name'];
|
$field['type'] = $type = $row['udt_name'];
|
||||||
|
|
||||||
if ($type == 'char' || $type == 'varchar') {
|
if ($type == 'char' || $type == 'varchar') {
|
||||||
if ($row['character_maximum_length'] !== null) {
|
if ($row['character_maximum_length'] !== null) {
|
||||||
@ -123,7 +115,7 @@ class PgsqlSchema extends Schema
|
|||||||
// These are inconvenient arrays with partial references to the
|
// These are inconvenient arrays with partial references to the
|
||||||
// pg_att table, but since we've already fetched up the column
|
// pg_att table, but since we've already fetched up the column
|
||||||
// info on the current table, we can look those up locally.
|
// info on the current table, we can look those up locally.
|
||||||
$cols = array();
|
$cols = [];
|
||||||
$colPositions = explode(' ', $row['indkey']);
|
$colPositions = explode(' ', $row['indkey']);
|
||||||
foreach ($colPositions as $ord) {
|
foreach ($colPositions as $ord) {
|
||||||
if ($ord == 0) {
|
if ($ord == 0) {
|
||||||
@ -139,13 +131,13 @@ class PgsqlSchema extends Schema
|
|||||||
// Pull constraint data from INFORMATION_SCHEMA:
|
// Pull constraint data from INFORMATION_SCHEMA:
|
||||||
// Primary key, unique keys, foreign keys
|
// Primary key, unique keys, foreign keys
|
||||||
$keyColumns = $this->fetchMetaInfo($table, 'key_column_usage', 'constraint_name,ordinal_position');
|
$keyColumns = $this->fetchMetaInfo($table, 'key_column_usage', 'constraint_name,ordinal_position');
|
||||||
$keys = array();
|
$keys = [];
|
||||||
|
|
||||||
foreach ($keyColumns as $row) {
|
foreach ($keyColumns as $row) {
|
||||||
$keyName = $row['constraint_name'];
|
$keyName = $row['constraint_name'];
|
||||||
$keyCol = $row['column_name'];
|
$keyCol = $row['column_name'];
|
||||||
if (!isset($keys[$keyName])) {
|
if (!isset($keys[$keyName])) {
|
||||||
$keys[$keyName] = array();
|
$keys[$keyName] = [];
|
||||||
}
|
}
|
||||||
$keys[$keyName][] = $keyCol;
|
$keys[$keyName][] = $keyCol;
|
||||||
}
|
}
|
||||||
@ -157,7 +149,7 @@ class PgsqlSchema extends Schema
|
|||||||
} else if (preg_match("/^{$table}_(.*)_fkey$/", $keyName, $matches)) {
|
} else if (preg_match("/^{$table}_(.*)_fkey$/", $keyName, $matches)) {
|
||||||
$fkey = $this->getForeignKeyInfo($table, $keyName);
|
$fkey = $this->getForeignKeyInfo($table, $keyName);
|
||||||
$colMap = array_combine($cols, $fkey['col_names']);
|
$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 {
|
} else {
|
||||||
$def['unique keys'][$keyName] = $cols;
|
$def['unique keys'][$keyName] = $cols;
|
||||||
}
|
}
|
||||||
@ -169,12 +161,15 @@ class PgsqlSchema extends Schema
|
|||||||
* Pull some INFORMATION.SCHEMA data for the given table.
|
* Pull some INFORMATION.SCHEMA data for the given table.
|
||||||
*
|
*
|
||||||
* @param string $table
|
* @param string $table
|
||||||
|
* @param $infoTable
|
||||||
|
* @param null $orderBy
|
||||||
* @return array of arrays
|
* @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 " .
|
$query = "SELECT * FROM information_schema.%s " .
|
||||||
"WHERE table_name='%s'";
|
"WHERE table_name='%s'";
|
||||||
$sql = sprintf($query, $infoTable, $table);
|
$sql = sprintf($query, $infoTable, $table);
|
||||||
if ($orderBy) {
|
if ($orderBy) {
|
||||||
$sql .= ' ORDER BY ' . $orderBy;
|
$sql .= ' ORDER BY ' . $orderBy;
|
||||||
@ -186,36 +181,39 @@ class PgsqlSchema extends Schema
|
|||||||
* Pull some PG-specific index info
|
* Pull some PG-specific index info
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array of arrays
|
* @return array of arrays
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
function getIndexInfo($table)
|
function getIndexInfo($table)
|
||||||
{
|
{
|
||||||
$query = 'SELECT ' .
|
$query = 'SELECT ' .
|
||||||
'(SELECT relname FROM pg_class WHERE oid=indexrelid) AS key_name, ' .
|
'(SELECT relname FROM pg_class WHERE oid=indexrelid) AS key_name, ' .
|
||||||
'* FROM pg_index ' .
|
'* FROM pg_index ' .
|
||||||
'WHERE indrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
|
'WHERE indrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
|
||||||
'AND indisprimary=\'f\' AND indisunique=\'f\' ' .
|
'AND indisprimary=\'f\' AND indisunique=\'f\' ' .
|
||||||
'ORDER BY indrelid, indexrelid';
|
'ORDER BY indrelid, indexrelid';
|
||||||
$sql = sprintf($query, $table);
|
$sql = sprintf($query, $table);
|
||||||
return $this->fetchQueryData($sql);
|
return $this->fetchQueryData($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Column names from the foreign table can be resolved with a call to getTableColumnNames()
|
* 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)
|
* @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)
|
function getForeignKeyInfo($table, $constraint_name)
|
||||||
{
|
{
|
||||||
// In a sane world, it'd be easier to query the column names directly.
|
// 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.
|
// But it's pretty hard to work with arrays such as col_indexes in direct SQL here.
|
||||||
$query = 'SELECT ' .
|
$query = 'SELECT ' .
|
||||||
'(SELECT relname FROM pg_class WHERE oid=confrelid) AS table_name, ' .
|
'(SELECT relname FROM pg_class WHERE oid=confrelid) AS table_name, ' .
|
||||||
'confrelid AS table_id, ' .
|
'confrelid AS table_id, ' .
|
||||||
'(SELECT indkey FROM pg_index WHERE indexrelid=conindid) AS col_indexes ' .
|
'(SELECT indkey FROM pg_index WHERE indexrelid=conindid) AS col_indexes ' .
|
||||||
'FROM pg_constraint ' .
|
'FROM pg_constraint ' .
|
||||||
'WHERE conrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
|
'WHERE conrelid=(SELECT oid FROM pg_class WHERE relname=\'%s\') ' .
|
||||||
'AND conname=\'%s\' ' .
|
'AND conname=\'%s\' ' .
|
||||||
'AND contype=\'f\'';
|
'AND contype=\'f\'';
|
||||||
$sql = sprintf($query, $table, $constraint_name);
|
$sql = sprintf($query, $table, $constraint_name);
|
||||||
$data = $this->fetchQueryData($sql);
|
$data = $this->fetchQueryData($sql);
|
||||||
if (count($data) < 1) {
|
if (count($data) < 1) {
|
||||||
@ -223,10 +221,10 @@ class PgsqlSchema extends Schema
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $data[0];
|
$row = $data[0];
|
||||||
return array(
|
return [
|
||||||
'table_name' => $row['table_name'],
|
'table_name' => $row['table_name'],
|
||||||
'col_names' => $this->getTableColumnNames($row['table_id'], $row['col_indexes'])
|
'col_names' => $this->getTableColumnNames($row['table_id'], $row['col_indexes'])
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,22 +232,23 @@ class PgsqlSchema extends Schema
|
|||||||
* @param int $table_id
|
* @param int $table_id
|
||||||
* @param array $col_indexes
|
* @param array $col_indexes
|
||||||
* @return array of strings
|
* @return array of strings
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
function getTableColumnNames($table_id, $col_indexes)
|
function getTableColumnNames($table_id, $col_indexes)
|
||||||
{
|
{
|
||||||
$indexes = array_map('intval', explode(' ', $col_indexes));
|
$indexes = array_map('intval', explode(' ', $col_indexes));
|
||||||
$query = 'SELECT attnum AS col_index, attname AS col_name ' .
|
$query = 'SELECT attnum AS col_index, attname AS col_name ' .
|
||||||
'FROM pg_attribute where attrelid=%d ' .
|
'FROM pg_attribute where attrelid=%d ' .
|
||||||
'AND attnum IN (%s)';
|
'AND attnum IN (%s)';
|
||||||
$sql = sprintf($query, $table_id, implode(',', $indexes));
|
$sql = sprintf($query, $table_id, implode(',', $indexes));
|
||||||
$data = $this->fetchQueryData($sql);
|
$data = $this->fetchQueryData($sql);
|
||||||
|
|
||||||
$byId = array();
|
$byId = [];
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
$byId[$row['col_index']] = $row['col_name'];
|
$byId[$row['col_index']] = $row['col_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = array();
|
$out = [];
|
||||||
foreach ($indexes as $id) {
|
foreach ($indexes as $id) {
|
||||||
$out[] = $byId[$id];
|
$out[] = $byId[$id];
|
||||||
}
|
}
|
||||||
@ -262,14 +261,15 @@ class PgsqlSchema extends Schema
|
|||||||
*
|
*
|
||||||
* @return string postgres happy column type
|
* @return string postgres happy column type
|
||||||
*/
|
*/
|
||||||
private function _columnTypeTranslation($type) {
|
private function _columnTypeTranslation($type)
|
||||||
$map = array(
|
{
|
||||||
'datetime' => 'timestamp',
|
$map = [
|
||||||
);
|
'datetime' => 'timestamp',
|
||||||
if(!empty($map[$type])) {
|
];
|
||||||
return $map[$type];
|
if (!empty($map[$type])) {
|
||||||
}
|
return $map[$type];
|
||||||
return $type;
|
}
|
||||||
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -286,7 +286,7 @@ class PgsqlSchema extends Schema
|
|||||||
|
|
||||||
function columnSql(array $cd)
|
function columnSql(array $cd)
|
||||||
{
|
{
|
||||||
$line = array();
|
$line = [];
|
||||||
$line[] = parent::columnSql($cd);
|
$line[] = parent::columnSql($cd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -341,7 +341,6 @@ class PgsqlSchema extends Schema
|
|||||||
* @param array $statements
|
* @param array $statements
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $def
|
|
||||||
*/
|
*/
|
||||||
function appendDropIndex(array &$statements, $table, $name)
|
function appendDropIndex(array &$statements, $table, $name)
|
||||||
{
|
{
|
||||||
@ -361,10 +360,12 @@ class PgsqlSchema extends Schema
|
|||||||
|
|
||||||
function mapType($column)
|
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.
|
$map = [
|
||||||
'numeric' => 'decimal',
|
'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.
|
||||||
'datetime' => 'timestamp',
|
'numeric' => 'decimal',
|
||||||
'blob' => 'bytea');
|
'datetime' => 'timestamp',
|
||||||
|
'blob' => 'bytea'
|
||||||
|
];
|
||||||
|
|
||||||
$type = $column['type'];
|
$type = $column['type'];
|
||||||
if (isset($map[$type])) {
|
if (isset($map[$type])) {
|
||||||
@ -390,7 +391,7 @@ class PgsqlSchema extends Schema
|
|||||||
function typeAndSize($column)
|
function typeAndSize($column)
|
||||||
{
|
{
|
||||||
if ($column['type'] == 'enum') {
|
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) . ')';
|
return "text check ($name in " . implode(',', $vals) . ')';
|
||||||
} else {
|
} else {
|
||||||
return parent::typeAndSize($column);
|
return parent::typeAndSize($column);
|
||||||
@ -405,6 +406,7 @@ class PgsqlSchema extends Schema
|
|||||||
* or type variants that we wouldn't get back from getTableDef().
|
* or type variants that we wouldn't get back from getTableDef().
|
||||||
*
|
*
|
||||||
* @param array $tableDef
|
* @param array $tableDef
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function filterDef(array $tableDef)
|
function filterDef(array $tableDef)
|
||||||
{
|
{
|
||||||
@ -444,8 +446,7 @@ class PgsqlSchema extends Schema
|
|||||||
function filterKeyDef(array $def)
|
function filterKeyDef(array $def)
|
||||||
{
|
{
|
||||||
// PostgreSQL doesn't like prefix lengths specified on keys...?
|
// PostgreSQL doesn't like prefix lengths specified on keys...?
|
||||||
foreach ($def as $i => $item)
|
foreach ($def as $i => $item) {
|
||||||
{
|
|
||||||
if (is_array($item)) {
|
if (is_array($item)) {
|
||||||
$def[$i] = $item[0];
|
$def[$i] = $item[0];
|
||||||
}
|
}
|
||||||
|
267
lib/schema.php
267
lib/schema.php
@ -1,35 +1,31 @@
|
|||||||
<?php
|
<?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
|
* @category Database
|
||||||
*
|
* @package GNUsocial
|
||||||
* PHP version 5
|
* @author Evan Prodromou <evan@status.net>
|
||||||
*
|
* @author Brion Vibber <brion@status.net>
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* 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/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing the database schema
|
* Class representing the database schema
|
||||||
@ -38,14 +34,9 @@ if (!defined('STATUSNET')) {
|
|||||||
* manipulate the schema -- especially for plugins and upgrade
|
* manipulate the schema -- especially for plugins and upgrade
|
||||||
* utilities.
|
* utilities.
|
||||||
*
|
*
|
||||||
* @category Database
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @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/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Schema
|
class Schema
|
||||||
{
|
{
|
||||||
static $_static = null;
|
static $_static = null;
|
||||||
@ -53,6 +44,7 @@ class Schema
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Only run once for singleton object.
|
* Constructor. Only run once for singleton object.
|
||||||
|
* @param null $conn
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected function __construct($conn = null)
|
protected function __construct($conn = null)
|
||||||
@ -72,6 +64,7 @@ class Schema
|
|||||||
* Main public entry point. Use this to get
|
* Main public entry point. Use this to get
|
||||||
* the schema object.
|
* the schema object.
|
||||||
*
|
*
|
||||||
|
* @param null $conn
|
||||||
* @return Schema the Schema object for the connection
|
* @return Schema the Schema object for the connection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -82,10 +75,10 @@ class Schema
|
|||||||
} else {
|
} else {
|
||||||
$key = md5(serialize($conn->dsn));
|
$key = md5(serialize($conn->dsn));
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = common_config('db', 'type');
|
$type = common_config('db', 'type');
|
||||||
if (empty(self::$_static[$key])) {
|
if (empty(self::$_static[$key])) {
|
||||||
$schemaClass = ucfirst($type).'Schema';
|
$schemaClass = ucfirst($type) . 'Schema';
|
||||||
self::$_static[$key] = new $schemaClass($conn);
|
self::$_static[$key] = new $schemaClass($conn);
|
||||||
}
|
}
|
||||||
return self::$_static[$key];
|
return self::$_static[$key];
|
||||||
@ -96,7 +89,7 @@ class Schema
|
|||||||
*
|
*
|
||||||
* Throws an exception if the table is not found.
|
* 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
|
* @param string $column name of the column
|
||||||
*
|
*
|
||||||
* @return ColumnDef definition of the column or null
|
* @return ColumnDef definition of the column or null
|
||||||
@ -121,10 +114,11 @@ class Schema
|
|||||||
/**
|
/**
|
||||||
* Creates a table with the given names and columns.
|
* Creates a table with the given names and columns.
|
||||||
*
|
*
|
||||||
* @param string $tableName Name of the table
|
* @param string $tableName Name of the table
|
||||||
* @param array $def Table definition array listing fields and indexes.
|
* @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)
|
public function createTable($tableName, $def)
|
||||||
@ -137,16 +131,17 @@ class Schema
|
|||||||
* Build a set of SQL statements to create a table with the given
|
* Build a set of SQL statements to create a table with the given
|
||||||
* name and columns.
|
* name and columns.
|
||||||
*
|
*
|
||||||
* @param string $name Name of the table
|
* @param string $name Name of the table
|
||||||
* @param array $def Table definition array
|
* @param array $def Table definition array
|
||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return array success flag
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function buildCreateTable($name, $def)
|
public function buildCreateTable($name, $def)
|
||||||
{
|
{
|
||||||
$def = $this->validateDef($name, $def);
|
$def = $this->validateDef($name, $def);
|
||||||
$def = $this->filterDef($def);
|
$def = $this->filterDef($def);
|
||||||
$sql = array();
|
$sql = [];
|
||||||
|
|
||||||
foreach ($def['fields'] as $col => $colDef) {
|
foreach ($def['fields'] as $col => $colDef) {
|
||||||
$this->appendColumnDef($sql, $col, $colDef);
|
$this->appendColumnDef($sql, $col, $colDef);
|
||||||
@ -171,10 +166,10 @@ class Schema
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wrap the CREATE TABLE around the main body chunks...
|
// Wrap the CREATE TABLE around the main body chunks...
|
||||||
$statements = array();
|
$statements = [];
|
||||||
$statements[] = $this->startCreateTable($name, $def) . "\n" .
|
$statements[] = $this->startCreateTable($name, $def) . "\n" .
|
||||||
implode($sql, ",\n") . "\n" .
|
implode($sql, ",\n") . "\n" .
|
||||||
$this->endCreateTable($name, $def);
|
$this->endCreateTable($name, $def);
|
||||||
|
|
||||||
// Multi-value indexes are advisory and for best portability
|
// Multi-value indexes are advisory and for best portability
|
||||||
// should be created as separate statements.
|
// should be created as separate statements.
|
||||||
@ -197,11 +192,11 @@ class Schema
|
|||||||
*
|
*
|
||||||
* @param string $name table name
|
* @param string $name table name
|
||||||
* @param array $def table definition
|
* @param array $def table definition
|
||||||
* @param $string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function startCreateTable($name, array $def)
|
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 array $sql
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $def
|
* @param array $def
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function appendForeignKeyDef(array &$sql, $name, array $def)
|
function appendForeignKeyDef(array &$sql, $name, array $def)
|
||||||
{
|
{
|
||||||
@ -270,11 +266,11 @@ class Schema
|
|||||||
$srcCols = array_keys($map);
|
$srcCols = array_keys($map);
|
||||||
$refCols = array_values($map);
|
$refCols = array_values($map);
|
||||||
$sql[] = "CONSTRAINT $name FOREIGN KEY " .
|
$sql[] = "CONSTRAINT $name FOREIGN KEY " .
|
||||||
$this->buildIndexList($srcCols) .
|
$this->buildIndexList($srcCols) .
|
||||||
" REFERENCES " .
|
" REFERENCES " .
|
||||||
$this->quoteIdentifier($refTable) .
|
$this->quoteIdentifier($refTable) .
|
||||||
" " .
|
" " .
|
||||||
$this->buildIndexList($refCols);
|
$this->buildIndexList($refCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,6 +295,7 @@ class Schema
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $def
|
* @param array $def
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function appendCreateFulltextIndex(array &$statements, $table, $name, array $def)
|
function appendCreateFulltextIndex(array &$statements, $table, $name, array $def)
|
||||||
{
|
{
|
||||||
@ -311,7 +308,6 @@ class Schema
|
|||||||
* @param array $statements
|
* @param array $statements
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $def
|
|
||||||
*/
|
*/
|
||||||
function appendDropIndex(array &$statements, $table, $name)
|
function appendDropIndex(array &$statements, $table, $name)
|
||||||
{
|
{
|
||||||
@ -321,7 +317,7 @@ class Schema
|
|||||||
function buildIndexList(array $def)
|
function buildIndexList(array $def)
|
||||||
{
|
{
|
||||||
// @fixme
|
// @fixme
|
||||||
return '(' . implode(',', array_map(array($this, 'buildIndexItem'), $def)) . ')';
|
return '(' . implode(',', array_map([$this, 'buildIndexItem'], $def)) . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildIndexItem($def)
|
function buildIndexItem($def)
|
||||||
@ -340,7 +336,8 @@ class Schema
|
|||||||
*
|
*
|
||||||
* @param string $name Name of the table to drop
|
* @param string $name Name of the table to drop
|
||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return bool success flag
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function dropTable($name)
|
public function dropTable($name)
|
||||||
@ -365,28 +362,29 @@ class Schema
|
|||||||
* Throws an exception on database error, esp. if the table
|
* Throws an exception on database error, esp. if the table
|
||||||
* does not exist.
|
* does not exist.
|
||||||
*
|
*
|
||||||
* @param string $table Name of the table
|
* @param string $table Name of the table
|
||||||
* @param array $columnNames Name of columns to index
|
* @param array $columnNames Name of columns to index
|
||||||
* @param string $name (Optional) name of the 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;
|
global $_PEAR;
|
||||||
|
|
||||||
if (!is_array($columnNames)) {
|
if (!is_array($columnNames)) {
|
||||||
$columnNames = array($columnNames);
|
$columnNames = [$columnNames];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
$name = "{$table}_".implode("_", $columnNames)."_idx";
|
$name = "{$table}_" . implode("_", $columnNames) . "_idx";
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $this->conn->query("ALTER TABLE $table ".
|
$res = $this->conn->query("ALTER TABLE $table " .
|
||||||
"ADD INDEX $name (".
|
"ADD INDEX $name (" .
|
||||||
implode(",", $columnNames).")");
|
implode(",", $columnNames) . ")");
|
||||||
|
|
||||||
if ($_PEAR->isError($res)) {
|
if ($_PEAR->isError($res)) {
|
||||||
PEAR_ErrorToPEAR_Exception($res);
|
PEAR_ErrorToPEAR_Exception($res);
|
||||||
@ -399,9 +397,10 @@ class Schema
|
|||||||
* Drops a named index from a table.
|
* Drops a named index from a table.
|
||||||
*
|
*
|
||||||
* @param string $table name of the table the index is on.
|
* @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)
|
public function dropIndex($table, $name)
|
||||||
@ -420,11 +419,12 @@ class Schema
|
|||||||
/**
|
/**
|
||||||
* Adds a column to a table
|
* 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
|
* @param ColumnDef $columndef Definition of the new
|
||||||
* column.
|
* column.
|
||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return bool success flag
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function addColumn($table, $columndef)
|
public function addColumn($table, $columndef)
|
||||||
@ -447,10 +447,11 @@ class Schema
|
|||||||
*
|
*
|
||||||
* The name must match an existing column and table.
|
* 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.
|
* @param ColumnDef $columndef new definition of the column.
|
||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return bool success flag
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function modifyColumn($table, $columndef)
|
public function modifyColumn($table, $columndef)
|
||||||
@ -458,7 +459,7 @@ class Schema
|
|||||||
global $_PEAR;
|
global $_PEAR;
|
||||||
|
|
||||||
$sql = "ALTER TABLE $table MODIFY COLUMN " .
|
$sql = "ALTER TABLE $table MODIFY COLUMN " .
|
||||||
$this->_columnSql($columndef);
|
$this->_columnSql($columndef);
|
||||||
|
|
||||||
$res = $this->conn->query($sql);
|
$res = $this->conn->query($sql);
|
||||||
|
|
||||||
@ -474,10 +475,11 @@ class Schema
|
|||||||
*
|
*
|
||||||
* The name must match an existing column.
|
* 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
|
* @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)
|
public function dropColumn($table, $columnName)
|
||||||
@ -504,9 +506,10 @@ class Schema
|
|||||||
* alter the table to match the column definitions.
|
* alter the table to match the column definitions.
|
||||||
*
|
*
|
||||||
* @param string $tableName name of the table
|
* @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)
|
public function ensureTable($tableName, $def)
|
||||||
@ -521,7 +524,8 @@ class Schema
|
|||||||
*
|
*
|
||||||
* @fixme if multiple statements, wrap in a transaction?
|
* @fixme if multiple statements, wrap in a transaction?
|
||||||
* @param array $statements
|
* @param array $statements
|
||||||
* @return boolean success flag
|
* @return bool success flag
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
function runSqlSet(array $statements)
|
function runSqlSet(array $statements)
|
||||||
{
|
{
|
||||||
@ -530,12 +534,12 @@ class Schema
|
|||||||
$ok = true;
|
$ok = true;
|
||||||
foreach ($statements as $sql) {
|
foreach ($statements as $sql) {
|
||||||
if (defined('DEBUG_INSTALLER')) {
|
if (defined('DEBUG_INSTALLER')) {
|
||||||
echo "<tt>" . htmlspecialchars($sql) . "</tt><br/>\n";
|
echo "<code>" . htmlspecialchars($sql) . "</code><br/>\n";
|
||||||
}
|
}
|
||||||
$res = $this->conn->query($sql);
|
$res = $this->conn->query($sql);
|
||||||
|
|
||||||
if ($_PEAR->isError($res)) {
|
if ($_PEAR->isError($res)) {
|
||||||
common_debug('PEAR exception on query: '.$sql);
|
common_debug('PEAR exception on query: ' . $sql);
|
||||||
PEAR_ErrorToPEAR_Exception($res);
|
PEAR_ErrorToPEAR_Exception($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -553,10 +557,9 @@ class Schema
|
|||||||
* match the column definitions.
|
* match the column definitions.
|
||||||
*
|
*
|
||||||
* @param string $tableName name of the table
|
* @param string $tableName name of the table
|
||||||
* @param array $columns array of ColumnDef
|
* @param array $def
|
||||||
* objects for the table
|
|
||||||
*
|
|
||||||
* @return array of SQL statements
|
* @return array of SQL statements
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function buildEnsureTable($tableName, array $def)
|
function buildEnsureTable($tableName, array $def)
|
||||||
@ -572,8 +575,8 @@ class Schema
|
|||||||
$def = $this->validateDef($tableName, $def);
|
$def = $this->validateDef($tableName, $def);
|
||||||
$def = $this->filterDef($def);
|
$def = $this->filterDef($def);
|
||||||
|
|
||||||
$statements = array();
|
$statements = [];
|
||||||
$fields = $this->diffArrays($old, $def, 'fields', array($this, 'columnsEqual'));
|
$fields = $this->diffArrays($old, $def, 'fields', [$this, 'columnsEqual']);
|
||||||
$uniques = $this->diffArrays($old, $def, 'unique keys');
|
$uniques = $this->diffArrays($old, $def, 'unique keys');
|
||||||
$indexes = $this->diffArrays($old, $def, 'indexes');
|
$indexes = $this->diffArrays($old, $def, 'indexes');
|
||||||
$foreign = $this->diffArrays($old, $def, 'foreign keys');
|
$foreign = $this->diffArrays($old, $def, 'foreign keys');
|
||||||
@ -592,7 +595,7 @@ class Schema
|
|||||||
// For efficiency, we want this all in one
|
// For efficiency, we want this all in one
|
||||||
// query, instead of using our methods.
|
// query, instead of using our methods.
|
||||||
|
|
||||||
$phrase = array();
|
$phrase = [];
|
||||||
|
|
||||||
foreach ($foreign['del'] + $foreign['mod'] as $keyName) {
|
foreach ($foreign['del'] + $foreign['mod'] as $keyName) {
|
||||||
$this->appendAlterDropForeign($phrase, $keyName);
|
$this->appendAlterDropForeign($phrase, $keyName);
|
||||||
@ -608,13 +611,13 @@ class Schema
|
|||||||
|
|
||||||
foreach ($fields['add'] as $columnName) {
|
foreach ($fields['add'] as $columnName) {
|
||||||
$this->appendAlterAddColumn($phrase, $columnName,
|
$this->appendAlterAddColumn($phrase, $columnName,
|
||||||
$def['fields'][$columnName]);
|
$def['fields'][$columnName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fields['mod'] as $columnName) {
|
foreach ($fields['mod'] as $columnName) {
|
||||||
$this->appendAlterModifyColumn($phrase, $columnName,
|
$this->appendAlterModifyColumn($phrase, $columnName,
|
||||||
$old['fields'][$columnName],
|
$old['fields'][$columnName],
|
||||||
$def['fields'][$columnName]);
|
$def['fields'][$columnName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fields['del'] as $columnName) {
|
foreach ($fields['del'] as $columnName) {
|
||||||
@ -653,19 +656,19 @@ class Schema
|
|||||||
return $statements;
|
return $statements;
|
||||||
}
|
}
|
||||||
|
|
||||||
function diffArrays($oldDef, $newDef, $section, $compareCallback=null)
|
function diffArrays($oldDef, $newDef, $section, $compareCallback = null)
|
||||||
{
|
{
|
||||||
$old = isset($oldDef[$section]) ? $oldDef[$section] : array();
|
$old = isset($oldDef[$section]) ? $oldDef[$section] : [];
|
||||||
$new = isset($newDef[$section]) ? $newDef[$section] : array();
|
$new = isset($newDef[$section]) ? $newDef[$section] : [];
|
||||||
|
|
||||||
$oldKeys = array_keys($old);
|
$oldKeys = array_keys($old);
|
||||||
$newKeys = array_keys($new);
|
$newKeys = array_keys($new);
|
||||||
|
|
||||||
$toadd = array_diff($newKeys, $oldKeys);
|
$toadd = array_diff($newKeys, $oldKeys);
|
||||||
$todrop = array_diff($oldKeys, $newKeys);
|
$todrop = array_diff($oldKeys, $newKeys);
|
||||||
$same = array_intersect($newKeys, $oldKeys);
|
$same = array_intersect($newKeys, $oldKeys);
|
||||||
$tomod = array();
|
$tomod = [];
|
||||||
$tokeep = array();
|
$tokeep = [];
|
||||||
|
|
||||||
// Find which fields have actually changed definition
|
// Find which fields have actually changed definition
|
||||||
// in a way that we need to tweak them for this DB type.
|
// in a way that we need to tweak them for this DB type.
|
||||||
@ -681,11 +684,13 @@ class Schema
|
|||||||
}
|
}
|
||||||
$tomod[] = $name;
|
$tomod[] = $name;
|
||||||
}
|
}
|
||||||
return array('add' => $toadd,
|
return [
|
||||||
'del' => $todrop,
|
'add' => $toadd,
|
||||||
'mod' => $tomod,
|
'del' => $todrop,
|
||||||
'keep' => $tokeep,
|
'mod' => $tomod,
|
||||||
'count' => count($toadd) + count($todrop) + count($tomod));
|
'keep' => $tokeep,
|
||||||
|
'count' => count($toadd) + count($todrop) + count($tomod)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -694,14 +699,14 @@ class Schema
|
|||||||
*
|
*
|
||||||
* @param array $phrase
|
* @param array $phrase
|
||||||
* @param string $columnName
|
* @param string $columnName
|
||||||
* @param array $cd
|
* @param array $cd
|
||||||
*/
|
*/
|
||||||
function appendAlterAddColumn(array &$phrase, $columnName, array $cd)
|
function appendAlterAddColumn(array &$phrase, $columnName, array $cd)
|
||||||
{
|
{
|
||||||
$phrase[] = 'ADD COLUMN ' .
|
$phrase[] = 'ADD COLUMN ' .
|
||||||
$this->quoteIdentifier($columnName) .
|
$this->quoteIdentifier($columnName) .
|
||||||
' ' .
|
' ' .
|
||||||
$this->columnSql($cd);
|
$this->columnSql($cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -716,9 +721,9 @@ class Schema
|
|||||||
function appendAlterModifyColumn(array &$phrase, $columnName, array $old, array $cd)
|
function appendAlterModifyColumn(array &$phrase, $columnName, array $old, array $cd)
|
||||||
{
|
{
|
||||||
$phrase[] = 'MODIFY COLUMN ' .
|
$phrase[] = 'MODIFY COLUMN ' .
|
||||||
$this->quoteIdentifier($columnName) .
|
$this->quoteIdentifier($columnName) .
|
||||||
' ' .
|
' ' .
|
||||||
$this->columnSql($cd);
|
$this->columnSql($cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -735,7 +740,7 @@ class Schema
|
|||||||
|
|
||||||
function appendAlterAddUnique(array &$phrase, $keyName, array $def)
|
function appendAlterAddUnique(array &$phrase, $keyName, array $def)
|
||||||
{
|
{
|
||||||
$sql = array();
|
$sql = [];
|
||||||
$sql[] = 'ADD';
|
$sql[] = 'ADD';
|
||||||
$this->appendUniqueKeyDef($sql, $keyName, $def);
|
$this->appendUniqueKeyDef($sql, $keyName, $def);
|
||||||
$phrase[] = implode(' ', $sql);
|
$phrase[] = implode(' ', $sql);
|
||||||
@ -743,7 +748,7 @@ class Schema
|
|||||||
|
|
||||||
function appendAlterAddForeign(array &$phrase, $keyName, array $def)
|
function appendAlterAddForeign(array &$phrase, $keyName, array $def)
|
||||||
{
|
{
|
||||||
$sql = array();
|
$sql = [];
|
||||||
$sql[] = 'ADD';
|
$sql[] = 'ADD';
|
||||||
$this->appendForeignKeyDef($sql, $keyName, $def);
|
$this->appendForeignKeyDef($sql, $keyName, $def);
|
||||||
$phrase[] = implode(' ', $sql);
|
$phrase[] = implode(' ', $sql);
|
||||||
@ -751,7 +756,7 @@ class Schema
|
|||||||
|
|
||||||
function appendAlterAddPrimary(array &$phrase, array $def)
|
function appendAlterAddPrimary(array &$phrase, array $def)
|
||||||
{
|
{
|
||||||
$sql = array();
|
$sql = [];
|
||||||
$sql[] = 'ADD';
|
$sql[] = 'ADD';
|
||||||
$this->appendPrimaryKeyDef($sql, $def);
|
$this->appendPrimaryKeyDef($sql, $def);
|
||||||
$phrase[] = implode(' ', $sql);
|
$phrase[] = implode(' ', $sql);
|
||||||
@ -809,7 +814,7 @@ class Schema
|
|||||||
*
|
*
|
||||||
* @param array $a
|
* @param array $a
|
||||||
* @param array $b
|
* @param array $b
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function columnsEqual(array $a, array $b)
|
function columnsEqual(array $a, array $b)
|
||||||
{
|
{
|
||||||
@ -827,7 +832,7 @@ class Schema
|
|||||||
|
|
||||||
protected function _names($cds)
|
protected function _names($cds)
|
||||||
{
|
{
|
||||||
$names = array();
|
$names = [];
|
||||||
|
|
||||||
foreach ($cds as $cd) {
|
foreach ($cds as $cd) {
|
||||||
$names[] = $cd->name;
|
$names[] = $cd->name;
|
||||||
@ -840,7 +845,7 @@ class Schema
|
|||||||
* Get a ColumnDef from an array matching
|
* Get a ColumnDef from an array matching
|
||||||
* name.
|
* name.
|
||||||
*
|
*
|
||||||
* @param array $cds Array of ColumnDef objects
|
* @param array $cds Array of ColumnDef objects
|
||||||
* @param string $name Name of the column
|
* @param string $name Name of the column
|
||||||
*
|
*
|
||||||
* @return ColumnDef matching item or null if no match.
|
* @return ColumnDef matching item or null if no match.
|
||||||
@ -864,14 +869,14 @@ class Schema
|
|||||||
* Appropriate for use in CREATE TABLE or
|
* Appropriate for use in CREATE TABLE or
|
||||||
* ALTER TABLE statements.
|
* ALTER TABLE statements.
|
||||||
*
|
*
|
||||||
* @param ColumnDef $cd column to create
|
* @param array $cd column to create
|
||||||
*
|
*
|
||||||
* @return string correct SQL for that column
|
* @return string correct SQL for that column
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function columnSql(array $cd)
|
function columnSql(array $cd)
|
||||||
{
|
{
|
||||||
$line = array();
|
$line = [];
|
||||||
$line[] = $this->typeAndSize($cd);
|
$line[] = $this->typeAndSize($cd);
|
||||||
|
|
||||||
if (isset($cd['default'])) {
|
if (isset($cd['default'])) {
|
||||||
@ -902,7 +907,7 @@ class Schema
|
|||||||
if (isset($column['size'])) {
|
if (isset($column['size'])) {
|
||||||
$type = $column['size'] . $type;
|
$type = $column['size'] . $type;
|
||||||
}
|
}
|
||||||
$lengths = array();
|
$lengths = [];
|
||||||
|
|
||||||
if (isset($column['precision'])) {
|
if (isset($column['precision'])) {
|
||||||
$lengths[] = $column['precision'];
|
$lengths[] = $column['precision'];
|
||||||
@ -926,20 +931,20 @@ class Schema
|
|||||||
* with plugins written for 0.9.x.
|
* with plugins written for 0.9.x.
|
||||||
*
|
*
|
||||||
* @param string $tableName
|
* @param string $tableName
|
||||||
* @param array $defs: array of ColumnDef objects
|
* @param array $defs : array of ColumnDef objects
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function oldToNew($tableName, array $defs)
|
protected function oldToNew($tableName, array $defs)
|
||||||
{
|
{
|
||||||
$table = array();
|
$table = [];
|
||||||
$prefixes = array(
|
$prefixes = [
|
||||||
'tiny',
|
'tiny',
|
||||||
'small',
|
'small',
|
||||||
'medium',
|
'medium',
|
||||||
'big',
|
'big',
|
||||||
);
|
];
|
||||||
foreach ($defs as $cd) {
|
foreach ($defs as $cd) {
|
||||||
$column = array();
|
$column = [];
|
||||||
$column['type'] = $cd->type;
|
$column['type'] = $cd->type;
|
||||||
foreach ($prefixes as $prefix) {
|
foreach ($prefixes as $prefix) {
|
||||||
if (substr($cd->type, 0, strlen($prefix)) == $prefix) {
|
if (substr($cd->type, 0, strlen($prefix)) == $prefix) {
|
||||||
@ -969,19 +974,19 @@ class Schema
|
|||||||
// If multiple columns are defined as primary key,
|
// If multiple columns are defined as primary key,
|
||||||
// we'll pile them on in sequence.
|
// we'll pile them on in sequence.
|
||||||
if (!isset($table['primary key'])) {
|
if (!isset($table['primary key'])) {
|
||||||
$table['primary key'] = array();
|
$table['primary key'] = [];
|
||||||
}
|
}
|
||||||
$table['primary key'][] = $cd->name;
|
$table['primary key'][] = $cd->name;
|
||||||
} else if ($cd->key == 'MUL') {
|
} else if ($cd->key == 'MUL') {
|
||||||
// Individual multiple-value indexes are only per-column
|
// Individual multiple-value indexes are only per-column
|
||||||
// using the old ColumnDef syntax.
|
// using the old ColumnDef syntax.
|
||||||
$idx = "{$tableName}_{$cd->name}_idx";
|
$idx = "{$tableName}_{$cd->name}_idx";
|
||||||
$table['indexes'][$idx] = array($cd->name);
|
$table['indexes'][$idx] = [$cd->name];
|
||||||
} else if ($cd->key == 'UNI') {
|
} else if ($cd->key == 'UNI') {
|
||||||
// Individual unique-value indexes are only per-column
|
// Individual unique-value indexes are only per-column
|
||||||
// using the old ColumnDef syntax.
|
// using the old ColumnDef syntax.
|
||||||
$idx = "{$tableName}_{$cd->name}_idx";
|
$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().
|
* or type variants that we wouldn't get back from getTableDef().
|
||||||
*
|
*
|
||||||
* @param array $tableDef
|
* @param array $tableDef
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function filterDef(array $tableDef)
|
function filterDef(array $tableDef)
|
||||||
{
|
{
|
||||||
@ -1008,7 +1014,7 @@ class Schema
|
|||||||
* If necessary, converts from an old-style array of ColumnDef objects.
|
* If necessary, converts from an old-style array of ColumnDef objects.
|
||||||
*
|
*
|
||||||
* @param string $tableName
|
* @param string $tableName
|
||||||
* @param array $def: table definition array
|
* @param array $def : table definition array
|
||||||
* @return array validated table definition array
|
* @return array validated table definition array
|
||||||
*
|
*
|
||||||
* @throws Exception on wildly invalid input
|
* @throws Exception on wildly invalid input
|
||||||
@ -1030,7 +1036,7 @@ class Schema
|
|||||||
function isNumericType($type)
|
function isNumericType($type)
|
||||||
{
|
{
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
$known = array('int', 'serial', 'numeric');
|
$known = ['int', 'serial', 'numeric'];
|
||||||
return in_array($type, $known);
|
return in_array($type, $known);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1039,6 +1045,7 @@ class Schema
|
|||||||
*
|
*
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @return array of arrays
|
* @return array of arrays
|
||||||
|
* @throws PEAR_Exception
|
||||||
*/
|
*/
|
||||||
protected function fetchQueryData($sql)
|
protected function fetchQueryData($sql)
|
||||||
{
|
{
|
||||||
@ -1049,8 +1056,8 @@ class Schema
|
|||||||
PEAR_ErrorToPEAR_Exception($res);
|
PEAR_ErrorToPEAR_Exception($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = array();
|
$out = [];
|
||||||
$row = array();
|
$row = [];
|
||||||
while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
|
while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
|
||||||
$out[] = $row;
|
$out[] = $row;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user