]> git.mxchange.org Git - friendica.git/blobdiff - database.sql
API: Added trending links
[friendica.git] / database.sql
index 48de2fcaef848dce71d36db99948010eb6d9dc6c..c68ae094c1aa5e11f531e980a9ae27fcebb663fa 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
--- Friendica 2022.09-rc (Giant Rhubarb)
--- DB_UPDATE_VERSION 1484
+-- Friendica 2022.12-dev (Giant Rhubarb)
+-- DB_UPDATE_VERSION 1492
 -- ------------------------------------------
 
 
@@ -80,7 +80,7 @@ CREATE TABLE IF NOT EXISTS `user` (
        `pwdreset` varchar(255) COMMENT 'Password reset request token',
        `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
        `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
-       `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
+       `expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
        `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
        `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
        `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
@@ -1186,6 +1186,7 @@ CREATE TABLE IF NOT EXISTS `post-content` (
        `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
        `body` mediumtext COMMENT 'item body content',
        `raw-body` mediumtext COMMENT 'Body without embedded media links',
+       `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
        `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
        `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
        `language` text COMMENT 'Language information about this post',
@@ -1202,7 +1203,9 @@ CREATE TABLE IF NOT EXISTS `post-content` (
         INDEX `plink` (`plink`(191)),
         INDEX `resource-id` (`resource-id`),
         FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
-       FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
+        INDEX `quote-uri-id` (`quote-uri-id`),
+       FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+       FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
 
 --
@@ -1289,6 +1292,7 @@ CREATE TABLE IF NOT EXISTS `post-media` (
        `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
        `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
        `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
+       `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
        `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
        `mimetype` varchar(60) COMMENT '',
        `height` smallint unsigned COMMENT 'Height of the media',
@@ -1308,7 +1312,9 @@ CREATE TABLE IF NOT EXISTS `post-media` (
         PRIMARY KEY(`id`),
         UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
         INDEX `uri-id-id` (`uri-id`,`id`),
-       FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
+        INDEX `media-uri-id` (`media-uri-id`),
+       FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+       FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
 
 --
@@ -1571,6 +1577,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
        `education` text COMMENT 'Deprecated',
        `contact` text COMMENT 'Deprecated',
        `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
+       `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
        `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
        `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
        `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
@@ -1639,6 +1646,35 @@ CREATE TABLE IF NOT EXISTS `register` (
        FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
 
+--
+-- TABLE report
+--
+CREATE TABLE IF NOT EXISTS `report` (
+       `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
+       `uid` mediumint unsigned COMMENT 'Reporting user',
+       `cid` int unsigned NOT NULL COMMENT 'Reported contact',
+       `comment` text COMMENT 'Report',
+       `forward` boolean COMMENT 'Forward the report to the remote server',
+       `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
+        PRIMARY KEY(`id`),
+        INDEX `uid` (`uid`),
+        INDEX `cid` (`cid`),
+       FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
+       FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
+
+--
+-- TABLE report-post
+--
+CREATE TABLE IF NOT EXISTS `report-post` (
+       `rid` int unsigned NOT NULL COMMENT 'Report id',
+       `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
+        PRIMARY KEY(`rid`,`uri-id`),
+        INDEX `uri-id` (`uri-id`),
+       FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+       FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
+
 --
 -- TABLE search
 --
@@ -1807,6 +1843,8 @@ CREATE VIEW `post-user-view` AS SELECT
        `post-user`.`thr-parent-id` AS `thr-parent-id`,
        `conversation-item-uri`.`uri` AS `conversation`,
        `post-thread-user`.`conversation-id` AS `conversation-id`,
+       `quote-item-uri`.`uri` AS `quote-uri`,
+       `post-content`.`quote-uri-id` AS `quote-uri-id`,
        `item-uri`.`guid` AS `guid`,
        `post-user`.`wall` AS `wall`,
        `post-user`.`gravity` AS `gravity`,
@@ -1944,9 +1982,7 @@ CREATE VIEW `post-user-view` AS SELECT
        `parent-post-author`.`url` AS `parent-author-link`,
        `parent-post-author`.`name` AS `parent-author-name`,
        `parent-post-author`.`nick` AS `parent-author-nick`,
-       `parent-post-author`.`network` AS `parent-author-network`,
-       `parent-post-author`.`blocked` AS `parent-author-blocked`,
-       `parent-post-author`.`hidden` AS `parent-author-hidden`
+       `parent-post-author`.`network` AS `parent-author-network`
        FROM `post-user`
                        STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
                        STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
@@ -1962,6 +1998,7 @@ CREATE VIEW `post-user-view` AS SELECT
                        LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
                        LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
                        LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
+                       LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
                        LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
                        LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
                        LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
@@ -1985,6 +2022,8 @@ CREATE VIEW `post-thread-user-view` AS SELECT
        `post-user`.`thr-parent-id` AS `thr-parent-id`,
        `conversation-item-uri`.`uri` AS `conversation`,
        `post-thread-user`.`conversation-id` AS `conversation-id`,
+       `quote-item-uri`.`uri` AS `quote-uri`,
+       `post-content`.`quote-uri-id` AS `quote-uri-id`,
        `item-uri`.`guid` AS `guid`,
        `post-thread-user`.`wall` AS `wall`,
        `post-user`.`gravity` AS `gravity`,
@@ -2120,9 +2159,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
        `parent-post`.`author-id` AS `parent-author-id`,
        `parent-post-author`.`url` AS `parent-author-link`,
        `parent-post-author`.`name` AS `parent-author-name`,
-       `parent-post-author`.`network` AS `parent-author-network`,
-       `parent-post-author`.`blocked` AS `parent-author-blocked`,
-       `parent-post-author`.`hidden` AS `parent-author-hidden`
+       `parent-post-author`.`network` AS `parent-author-network`
        FROM `post-thread-user`
                        INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
                        STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
@@ -2138,6 +2175,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
                        LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
                        LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
                        LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
+                       LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
                        LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
                        LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
                        LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
@@ -2157,6 +2195,8 @@ CREATE VIEW `post-view` AS SELECT
        `post`.`thr-parent-id` AS `thr-parent-id`,
        `conversation-item-uri`.`uri` AS `conversation`,
        `post-thread`.`conversation-id` AS `conversation-id`,
+       `quote-item-uri`.`uri` AS `quote-uri`,
+       `post-content`.`quote-uri-id` AS `quote-uri-id`,
        `item-uri`.`guid` AS `guid`,
        `post`.`gravity` AS `gravity`,
        `external-item-uri`.`uri` AS `extid`,
@@ -2263,9 +2303,7 @@ CREATE VIEW `post-view` AS SELECT
        `parent-post`.`author-id` AS `parent-author-id`,
        `parent-post-author`.`url` AS `parent-author-link`,
        `parent-post-author`.`name` AS `parent-author-name`,
-       `parent-post-author`.`network` AS `parent-author-network`,
-       `parent-post-author`.`blocked` AS `parent-author-blocked`,
-       `parent-post-author`.`hidden` AS `parent-author-hidden`
+       `parent-post-author`.`network` AS `parent-author-network`
        FROM `post`
                        STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
                        STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
@@ -2279,6 +2317,7 @@ CREATE VIEW `post-view` AS SELECT
                        LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
                        LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
                        LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
+                       LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
                        LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
                        LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
                        LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
@@ -2296,6 +2335,8 @@ CREATE VIEW `post-thread-view` AS SELECT
        `post`.`thr-parent-id` AS `thr-parent-id`,
        `conversation-item-uri`.`uri` AS `conversation`,
        `post-thread`.`conversation-id` AS `conversation-id`,
+       `quote-item-uri`.`uri` AS `quote-uri`,
+       `post-content`.`quote-uri-id` AS `quote-uri-id`,
        `item-uri`.`guid` AS `guid`,
        `post`.`gravity` AS `gravity`,
        `external-item-uri`.`uri` AS `extid`,
@@ -2396,15 +2437,15 @@ CREATE VIEW `post-thread-view` AS SELECT
        `post-question`.`end-time` AS `question-end-time`,
        0 AS `has-categories`,
        EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
+       (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
+       (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
        `diaspora-interaction`.`interaction` AS `signed_text`,
        `parent-item-uri`.`guid` AS `parent-guid`,
        `parent-post`.`network` AS `parent-network`,
        `parent-post`.`author-id` AS `parent-author-id`,
        `parent-post-author`.`url` AS `parent-author-link`,
        `parent-post-author`.`name` AS `parent-author-name`,
-       `parent-post-author`.`network` AS `parent-author-network`,
-       `parent-post-author`.`blocked` AS `parent-author-blocked`,
-       `parent-post-author`.`hidden` AS `parent-author-hidden`
+       `parent-post-author`.`network` AS `parent-author-network`
        FROM `post-thread`
                        INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
                        STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
@@ -2418,6 +2459,7 @@ CREATE VIEW `post-thread-view` AS SELECT
                        LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
                        LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
                        LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
+                       LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
                        LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
                        LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
                        LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
@@ -2656,6 +2698,7 @@ CREATE VIEW `owner-view` AS SELECT
        `profile`.`postal-code` AS `postal-code`,
        `profile`.`country-name` AS `country-name`,
        `profile`.`homepage` AS `homepage`,
+       `profile`.`homepage_verified` AS `homepage_verified`,
        `profile`.`dob` AS `dob`
        FROM `user`
                        INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`