From 8f27715d8b864fb31bf96ba481f1a10c7d70659c Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 Feb 2021 13:42:21 +0000 Subject: [PATCH 1/2] "item" is replaced whenever possible at the moment --- src/Database/DBA.php | 4 ++-- src/Database/Database.php | 4 ++-- src/Model/Item.php | 8 ++++---- src/Module/Admin/Site.php | 2 +- src/Module/Settings/UserExport.php | 2 +- src/Worker/CleanItemUri.php | 3 ++- src/Worker/Expire.php | 5 +++-- src/Worker/MergeContact.php | 12 +++++------- src/Worker/RepairDatabase.php | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 41ab456b8..3bdcfb617 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -478,7 +478,7 @@ class DBA * @return boolean|object * * Example: - * $table = "item"; + * $table = "post"; * $fields = array("id", "uri", "uid", "network"); * * $condition = array("uid" => 1, "network" => 'dspr'); @@ -505,7 +505,7 @@ class DBA * @return int * * Example: - * $table = "item"; + * $table = "post"; * * $condition = ["uid" => 1, "network" => 'dspr']; * or: diff --git a/src/Database/Database.php b/src/Database/Database.php index ae06f00e2..ec95a8301 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1512,7 +1512,7 @@ class Database * * * Example: - * $table = 'item'; + * $table = 'post'; * or: * $table = ['schema' => 'table']; * @see DBA::buildTableString() @@ -1575,7 +1575,7 @@ class Database * @return int * * Example: - * $table = "item"; + * $table = "post"; * * $condition = ["uid" => 1, "network" => 'dspr']; * or: diff --git a/src/Model/Item.php b/src/Model/Item.php index 106d50e76..8eeb77d32 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -319,7 +319,7 @@ class Item // Set the item to "deleted" $item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()]; - DBA::update('item', $item_fields, ['id' => $item['id']]); + Post::update($item_fields, ['id' => $item['id']]); Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], ''); self::deleteThread($item['id'], $item['parent-uri-id']); @@ -919,7 +919,7 @@ class Item $item["global"] = true; // Set the global flag on all items if this was a global item entry - DBA::update('item', ['global' => true], ['uri-id' => $item['uri-id']]); + Post::update(['global' => true], ['uri-id' => $item['uri-id']]); } else { $item['global'] = Post::exists(['uid' => 0, 'uri-id' => $item['uri-id']]); } @@ -1068,9 +1068,9 @@ class Item } if ($update_commented) { - DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); + Post::update(['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); } else { - DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); + Post::update(['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); } if ($item['gravity'] === GRAVITY_PARENT) { diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 0e0753a40..8cd2648cf 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -104,7 +104,7 @@ class Site extends BaseAdmin // update profile links in the format "http://server.tld" update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url); update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url); - update_table($a, "item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url); + update_table($a, "post-content", ['body'], $old_url, $new_url); // update profile addresses in the format "user@server.tld" update_table($a, "contact", ['addr'], $old_host, $new_host); diff --git a/src/Module/Settings/UserExport.php b/src/Module/Settings/UserExport.php index 42ee4eb1f..2b668182e 100644 --- a/src/Module/Settings/UserExport.php +++ b/src/Module/Settings/UserExport.php @@ -242,7 +242,7 @@ class UserExport extends BaseSettings self::exportAccount($a); echo "\n"; - $total = DBA::count('item', ['uid' => local_user()]); + $total = Post::count(['uid' => local_user()]); // chunk the output to avoid exhausting memory for ($x = 0; $x < $total; $x += 500) { diff --git a/src/Worker/CleanItemUri.php b/src/Worker/CleanItemUri.php index d7a99153f..268fe29dc 100644 --- a/src/Worker/CleanItemUri.php +++ b/src/Worker/CleanItemUri.php @@ -23,6 +23,7 @@ namespace Friendica\Worker; use Friendica\Core\Logger; use Friendica\Database\DBA; +use Friendica\Model\Post; class CleanItemUri { @@ -33,7 +34,7 @@ class CleanItemUri { // We have to avoid deleting newly created "item-uri" entries. // So we fetch a post that had been stored yesterday and only delete older ones. - $item = DBA::selectFirst('item', ['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1], + $item = Post::selectFirst(['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1], ['order' => ['received' => true]]); if (empty($item['uri-id'])) { Logger::warning('No item with uri-id found - we better quit here'); diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 70a4f913a..ca92bd1ee 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -44,11 +44,12 @@ class Expire Logger::log('Delete expired items', Logger::DEBUG); // physically remove anything that has been deleted for more than two months $condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"]; - $rows = DBA::select('item', ['id', 'guid', 'uri-id', 'uid'], $condition); - while ($row = DBA::fetch($rows)) { + $rows = Post::select(['id', 'guid', 'uri-id', 'uid'], $condition); + while ($row = Post::fetch($rows)) { Logger::info('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]); DBA::delete('item', ['id' => $row['id']]); Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]); + Post\ThreadUser::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]); } DBA::close($rows); diff --git a/src/Worker/MergeContact.php b/src/Worker/MergeContact.php index e04dfb6ac..7a4c07540 100644 --- a/src/Worker/MergeContact.php +++ b/src/Worker/MergeContact.php @@ -23,6 +23,7 @@ namespace Friendica\Worker; use Friendica\Core\Logger; use Friendica\Database\DBA; +use Friendica\Model\Post; class MergeContact { @@ -43,8 +44,7 @@ class MergeContact Logger::info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]); // Search and replace - DBA::update('item', ['contact-id' => $new_cid], ['contact-id' => $old_cid]); - DBA::update('thread', ['contact-id' => $new_cid], ['contact-id' => $old_cid]); + Post::update(['contact-id' => $new_cid], ['contact-id' => $old_cid]); DBA::update('mail', ['contact-id' => $new_cid], ['contact-id' => $old_cid]); DBA::update('photo', ['contact-id' => $new_cid], ['contact-id' => $old_cid]); DBA::update('event', ['cid' => $new_cid], ['cid' => $old_cid]); @@ -53,11 +53,9 @@ class MergeContact if ($uid == 0) { DBA::update('post-tag', ['cid' => $new_cid], ['cid' => $old_cid]); DBA::delete('post-tag', ['cid' => $old_cid]); - DBA::update('item', ['author-id' => $new_cid], ['author-id' => $old_cid]); - DBA::update('item', ['owner-id' => $new_cid], ['owner-id' => $old_cid]); - DBA::update('item', ['causer-id' => $new_cid], ['causer-id' => $old_cid]); - DBA::update('thread', ['author-id' => $new_cid], ['author-id' => $old_cid]); - DBA::update('thread', ['owner-id' => $new_cid], ['owner-id' => $old_cid]); + Post::update(['author-id' => $new_cid], ['author-id' => $old_cid]); + Post::update(['owner-id' => $new_cid], ['owner-id' => $old_cid]); + Post::update(['causer-id' => $new_cid], ['causer-id' => $old_cid]); } else { /// @todo Check if some other data needs to be adjusted as well, possibly the "rel" status? } diff --git a/src/Worker/RepairDatabase.php b/src/Worker/RepairDatabase.php index 3524c3d15..ef9035d89 100644 --- a/src/Worker/RepairDatabase.php +++ b/src/Worker/RepairDatabase.php @@ -26,7 +26,7 @@ use Friendica\Model\ItemURI; /** * Do some repairs in database entries - * + * @todo This class can be deleted without replacement when the item table is removed */ class RepairDatabase { From ab5a447bc2261522d0f5560f8933dd928a6fc6e3 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 8 Feb 2021 07:48:36 +0000 Subject: [PATCH 2/2] The "thread" table isn't used anymore --- database.sql | 51 ----------------------- src/Database/DBStructure.php | 2 +- src/Model/Item.php | 77 ----------------------------------- src/Model/Post.php | 12 ------ src/Worker/ExpirePosts.php | 26 ++++++------ static/dbstructure.config.php | 47 --------------------- 6 files changed, 13 insertions(+), 202 deletions(-) diff --git a/database.sql b/database.sql index 98aa1620e..4ad484e19 100644 --- a/database.sql +++ b/database.sql @@ -1380,57 +1380,6 @@ CREATE TABLE IF NOT EXISTS `storage` ( PRIMARY KEY(`id`) ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend'; --- --- TABLE thread --- -CREATE TABLE IF NOT EXISTS `thread` ( - `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID', - `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri', - `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id', - `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '', - `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner', - `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author', - `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', - `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', - `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', - `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', - `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', - `wall` boolean NOT NULL DEFAULT '0' COMMENT '', - `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted', - `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '', - `moderated` boolean NOT NULL DEFAULT '0' COMMENT '', - `visible` boolean NOT NULL DEFAULT '0' COMMENT '', - `starred` boolean NOT NULL DEFAULT '0' COMMENT '', - `ignored` boolean NOT NULL DEFAULT '0' COMMENT '', - `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)', - `unseen` boolean NOT NULL DEFAULT '1' COMMENT '', - `deleted` boolean NOT NULL DEFAULT '0' COMMENT '', - `origin` boolean NOT NULL DEFAULT '0' COMMENT '', - `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '', - `mention` boolean NOT NULL DEFAULT '0' COMMENT '', - `network` char(4) NOT NULL DEFAULT '' COMMENT '', - `bookmark` boolean COMMENT '', - PRIMARY KEY(`iid`), - INDEX `uid_network_commented` (`uid`,`network`,`commented`), - INDEX `uid_network_received` (`uid`,`network`,`received`), - INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`), - INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`), - INDEX `contactid` (`contact-id`), - INDEX `ownerid` (`owner-id`), - INDEX `authorid` (`author-id`), - INDEX `uid_received` (`uid`,`received`), - INDEX `uid_commented` (`uid`,`commented`), - INDEX `uid_wall_received` (`uid`,`wall`,`received`), - INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`), - INDEX `uri-id` (`uri-id`), - FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, - FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, - FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, - FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, - FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT, - FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data'; - -- -- TABLE tokens -- diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index b9e53be04..6ad6bb527 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -80,7 +80,7 @@ class DBStructure $old_tables = ['fserver', 'gcign', 'gcontact', 'gcontact-relation', 'gfollower' ,'glink', 'item-delivery-data', 'item-activity', 'item-content', 'item_id', 'participation', 'poll', 'poll_result', 'queue', 'retriever_rule', - 'sign', 'spam', 'term', 'user-item']; + 'sign', 'spam', 'term', 'thread', 'user-item']; $tables = DBA::selectToArray(['INFORMATION_SCHEMA' => 'TABLES'], ['TABLE_NAME'], ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']); diff --git a/src/Model/Item.php b/src/Model/Item.php index 8eeb77d32..cd484e678 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -322,7 +322,6 @@ class Item Post::update($item_fields, ['id' => $item['id']]); Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], ''); - self::deleteThread($item['id'], $item['parent-uri-id']); if (!Post::exists(["`uri-id` = ? AND `uid` != 0 AND NOT `deleted`", $item['uri-id']])) { self::markForDeletion(['uri-id' => $item['uri-id'], 'uid' => 0, 'deleted' => false], $priority); @@ -900,7 +899,6 @@ class Item // If its a post that originated here then tag the thread as "mention" if ($item['origin'] && $item['uid']) { DBA::update('post-thread-user', ['mention' => true], ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]); - DBA::update('thread', ['mention' => true], ['iid' => $parent_id]); Logger::info('tagged thread as mention', ['parent' => $parent_id, 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]); } @@ -1073,12 +1071,6 @@ class Item Post::update(['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); } - if ($item['gravity'] === GRAVITY_PARENT) { - self::addThread($current_post); - } else { - self::updateThread($parent_id); - } - // In that function we check if this is a forum post. Additionally we delete the item under certain circumstances if (self::tagDeliver($item['uid'], $current_post)) { // Get the user information for the logging @@ -2423,75 +2415,6 @@ class Item return true; } - private static function addThread($itemid, $onlyshadow = false) - { - $fields = ['uid', 'created', 'edited', 'commented', 'received', 'changed', 'wall', 'private', 'pubmail', - 'moderated', 'visible', 'starred', 'contact-id', 'post-type', 'uri-id', - 'deleted', 'origin', 'forum_mode', 'mention', 'network', 'author-id', 'owner-id']; - $condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid]; - $item = Post::selectFirst($fields, $condition); - - if (!DBA::isResult($item)) { - return; - } - - $item['iid'] = $itemid; - - if (!$onlyshadow) { - $result = DBA::replace('thread', $item); - - Logger::info('Add thread', ['item' => $itemid, 'result' => $result]); - } - } - - private static function updateThread($itemid, $setmention = false) - { - $fields = ['uid', 'guid', 'created', 'edited', 'commented', 'received', 'changed', 'post-type', - 'wall', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'contact-id', 'uri-id', - 'deleted', 'origin', 'forum_mode', 'network', 'author-id', 'owner-id']; - - $item = Post::selectFirst($fields, ['id' => $itemid, 'gravity' => GRAVITY_PARENT]); - if (!DBA::isResult($item)) { - return; - } - - if ($setmention) { - $item["mention"] = 1; - } - - $fields = []; - - foreach ($item as $field => $data) { - if (!in_array($field, ["guid"])) { - $fields[$field] = $data; - } - } - - $result = DBA::update('thread', $fields, ['iid' => $itemid]); - - Logger::info('Update thread', ['item' => $itemid, 'guid' => $item["guid"], 'result' => $result]); - } - - private static function deleteThread($itemid, $uri_id) - { - $item = DBA::selectFirst('thread', ['uid'], ['iid' => $itemid]); - if (!DBA::isResult($item)) { - Logger::info('No thread found', ['id' => $itemid]); - return; - } - - $result = DBA::delete('thread', ['iid' => $itemid], ['cascade' => false]); - - Logger::info('Deleted thread', ['item' => $itemid, 'result' => $result]); - - $condition = ["`uri-id` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $uri_id, $item["uid"]]; - if (!Post::exists($condition)) { - DBA::delete('item', ['uri-id' => $uri_id, 'uid' => 0]); - Post\User::delete(['uri-id' => $uri_id, 'uid' => 0]); - Logger::debug('Deleted shadow item', ['id' => $itemid, 'uri-id' => $uri_id]); - } - } - /** * Fetch the SQL condition for the given user id * diff --git a/src/Model/Post.php b/src/Model/Post.php index d4aa9f1ee..29cbb2695 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -477,18 +477,6 @@ class Post $affected = max($affected, DBA::affectedRows()); } - $update_fields = DBStructure::getFieldsForTable('thread', $fields); - if (!empty($update_fields)) { - $rows = DBA::selectToArray('post-view', ['id'], $thread_condition); - $ids = array_column($rows, 'id'); - if (!DBA::update('thread', $update_fields, ['iid' => $ids])) { - DBA::rollback(); - Logger::notice('Updating thread failed', ['fields' => $update_fields, 'condition' => $thread_condition]); - return false; - } - $affected = max($affected, DBA::affectedRows()); - } - $update_fields = []; foreach (Item::USED_FIELDLIST as $field) { if (array_key_exists($field, $fields)) { diff --git a/src/Worker/ExpirePosts.php b/src/Worker/ExpirePosts.php index 010aef696..61343566d 100644 --- a/src/Worker/ExpirePosts.php +++ b/src/Worker/ExpirePosts.php @@ -25,6 +25,7 @@ use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Model\Item; class ExpirePosts { @@ -47,21 +48,18 @@ class ExpirePosts if (!empty($expire_days)) { do { Logger::notice('Start deleting expired threads', ['expiry_days' => $expire_days]); - /// @todo replace that query later $ret = DBA::e("DELETE FROM `item-uri` WHERE `id` IN - (SELECT `uri-id` FROM `thread` - INNER JOIN `contact` ON `id` = `contact-id` AND NOT `notify_new_posts` - WHERE `thread`.`received` < UTC_TIMESTAMP() - INTERVAL ? DAY - AND NOT `thread`.`mention` AND NOT `thread`.`starred` - AND NOT `thread`.`wall` AND NOT `thread`.`origin` - AND `thread`.`uid` != 0 AND NOT `iid` IN (SELECT `parent` FROM `item` - WHERE (`item`.`starred` OR (`item`.`resource-id` != '') - OR (`item`.`event-id` != '') OR (`item`.`attach` != '') - OR `item`.`wall` OR `item`.`origin` - OR `item`.`uri-id` IN (SELECT `uri-id` FROM `post-category` - WHERE `post-category`.`uri-id` = `item`.`uri-id`)) - AND `item`.`parent` = `thread`.`iid`)) - ORDER BY `id` LIMIT ?", $expire_days, $limit); + (SELECT `uri-id` FROM `post-thread` WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY + AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-thread-user` WHERE (`mention` OR `starred` OR `wall` OR `pinned`) AND `uri-id` = `post-thread`.`uri-id`) + AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin` AND `uri-id` = `post-thread`.`uri-id`) + AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-category` WHERE `uri-id` = `post-thread`.`uri-id`) + AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `uri-id` = `post-thread`.`uri-id`) + AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `contact-id` AND `notify_new_posts` + WHERE `parent-uri-id` = `post-thread`.`uri-id`) + AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` + WHERE (`origin` OR `starred` OR `resource-id` != 0 OR `event-id` != 0 OR `wall` OR `attach` != '' OR `post-type` = ?) + AND `parent-uri-id` = `post-thread`.`uri-id`)) + ORDER BY `id` LIMIT ?", $expire_days, Item::PT_PERSONAL_NOTE, $limit); $rows = DBA::affectedRows(); Logger::notice('Deleted expired threads', ['result' => $ret, 'rows' => $rows]); diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 370479b99..1a120969d 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -1429,53 +1429,6 @@ return [ "PRIMARY" => ["id"] ] ], - "thread" => [ - "comment" => "Thread related data", - "fields" => [ - "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "foreign" => ["item" => "id"], - "comment" => "sequential ID"], - "uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "User id"], - "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => ""], - "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Item owner"], - "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Item author"], - "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], - "edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], - "commented" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], - "received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], - "changed" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], - "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "private" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "0=public, 1=private, 2=unlisted"], - "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"], - "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""], - "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""], - "bookmark" => ["type" => "boolean", "comment" => ""], - ], - "indexes" => [ - "PRIMARY" => ["iid"], - "uid_network_commented" => ["uid", "network", "commented"], - "uid_network_received" => ["uid", "network", "received"], - "uid_contactid_commented" => ["uid", "contact-id", "commented"], - "uid_contactid_received" => ["uid", "contact-id", "received"], - "contactid" => ["contact-id"], - "ownerid" => ["owner-id"], - "authorid" => ["author-id"], - "uid_received" => ["uid", "received"], - "uid_commented" => ["uid", "commented"], - "uid_wall_received" => ["uid", "wall", "received"], - "private_wall_origin_commented" => ["private", "wall", "origin", "commented"], - "uri-id" => ["uri-id"], - ] - ], "tokens" => [ "comment" => "OAuth usage", "fields" => [