Merge pull request #8705 from annando/thread-uri-id
Add "uri-id" to the "thread" table
This commit is contained in:
commit
0efd3dedeb
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2020.06-dev (Red Hot Poker)
|
||||
-- DB_UPDATE_VERSION 1350
|
||||
-- DB_UPDATE_VERSION 1351
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -1237,6 +1237,7 @@ CREATE TABLE IF NOT EXISTS `storage` (
|
|||
--
|
||||
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',
|
||||
|
@ -1272,7 +1273,9 @@ CREATE TABLE IF NOT EXISTS `thread` (
|
|||
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 `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
|
||||
INDEX `uri-id` (`uri-id`),
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
|
||||
|
||||
--
|
||||
|
|
|
@ -3110,7 +3110,7 @@ class Item
|
|||
private static function addThread($itemid, $onlyshadow = false)
|
||||
{
|
||||
$fields = ['uid', 'created', 'edited', 'commented', 'received', 'changed', 'wall', 'private', 'pubmail',
|
||||
'moderated', 'visible', 'starred', 'contact-id', 'post-type',
|
||||
'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 = self::selectFirst($fields, $condition);
|
||||
|
@ -3131,7 +3131,7 @@ class Item
|
|||
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',
|
||||
'wall', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'contact-id', 'uri-id',
|
||||
'deleted', 'origin', 'forum_mode', 'network', 'author-id', 'owner-id'];
|
||||
$condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid];
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1350);
|
||||
define('DB_UPDATE_VERSION', 1351);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -1343,6 +1343,7 @@ return [
|
|||
"fields" => [
|
||||
"iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["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", "relation" => ["user" => "uid"], "comment" => "User id"],
|
||||
"contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
|
||||
"owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"],
|
||||
|
@ -1381,6 +1382,7 @@ return [
|
|||
"uid_commented" => ["uid", "commented"],
|
||||
"uid_wall_received" => ["uid", "wall", "received"],
|
||||
"private_wall_origin_commented" => ["private", "wall", "origin", "commented"],
|
||||
"uri-id" => ["uri-id"],
|
||||
]
|
||||
],
|
||||
"tokens" => [
|
||||
|
|
|
@ -268,6 +268,7 @@ return [
|
|||
'thread' => [
|
||||
[
|
||||
'iid' => 1,
|
||||
'uri-id' => 1,
|
||||
'visible' => 1,
|
||||
'contact-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -277,6 +278,7 @@ return [
|
|||
],
|
||||
[
|
||||
'iid' => 3,
|
||||
'uri-id' => 3,
|
||||
'visible' => 1,
|
||||
'contact-id' => 43,
|
||||
'author-id' => 43,
|
||||
|
@ -286,6 +288,7 @@ return [
|
|||
],
|
||||
[
|
||||
'iid' => 6,
|
||||
'uri-id' => 6,
|
||||
'visible' => 1,
|
||||
'contact-id' => 44,
|
||||
'author-id' => 44,
|
||||
|
|
11
update.php
11
update.php
|
@ -498,4 +498,13 @@ function update_1349()
|
|||
}
|
||||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
function update_1351()
|
||||
{
|
||||
if (!DBA::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id` SET `thread`.`uri-id` = `item`.`uri-id`")) {
|
||||
return Update::FAILED;
|
||||
}
|
||||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue