]> git.mxchange.org Git - friendica.git/blobdiff - database.sql
Accept "application/json" as application type for ActivityPub
[friendica.git] / database.sql
index 987a2d7e20bb1f7083f26b1dc46aa0756c5f58a0..33c32cec0a9e07cf546d7becb07b94713405d9b2 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2021.03-dev (Red Hot Poker)
--- DB_UPDATE_VERSION 1393
+-- DB_UPDATE_VERSION 1395
 -- ------------------------------------------
 
 
@@ -283,10 +283,24 @@ CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
        `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
        `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
        `used` datetime COMMENT 'Datetime the code was used',
-        PRIMARY KEY(`uid`,`code`),
+       PRIMARY KEY(`uid`,`code`),
        FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
 
+--
+-- TABLE 2fa_trusted_browser
+--
+CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
+    `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
+    `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
+    `user_agent` text COMMENT 'User agent string',
+    `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
+    `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
+    PRIMARY KEY(`cookie_hash`),
+    INDEX `uid` (`uid`),
+    FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
+
 --
 -- TABLE addon
 --
@@ -1153,6 +1167,7 @@ CREATE TABLE IF NOT EXISTS `post-tag` (
 -- TABLE post-user
 --
 CREATE TABLE IF NOT EXISTS `post-user` (
+       `id` int unsigned NOT NULL auto_increment,
        `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
        `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
        `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
@@ -1162,7 +1177,8 @@ CREATE TABLE IF NOT EXISTS `post-user` (
        `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
        `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
        `psid` int unsigned COMMENT 'ID of the permission set of this post',
-        PRIMARY KEY(`uid`,`uri-id`),
+        PRIMARY KEY(`id`),
+        UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
         INDEX `uri-id` (`uri-id`),
         INDEX `contact-id` (`contact-id`),
         INDEX `psid` (`psid`),
@@ -1493,12 +1509,11 @@ DROP VIEW IF EXISTS `post-view`;
 CREATE VIEW `post-view` AS SELECT 
        `item`.`id` AS `id`,
        `item`.`id` AS `item_id`,
+       `post-user`.`id` AS `post-user-id`,
        `item`.`uid` AS `uid`,
-       `item`.`uid` AS `internal-uid`,
        `item`.`parent` AS `parent`,
        `item`.`uri` AS `uri`,
        `item`.`uri-id` AS `uri-id`,
-       `item`.`uri-id` AS `internal-uri-id`,
        `item`.`parent-uri` AS `parent-uri`,
        `item`.`parent-uri-id` AS `parent-uri-id`,
        `item`.`thr-parent` AS `thr-parent`,
@@ -1530,9 +1545,6 @@ CREATE VIEW `post-view` AS SELECT
        `item`.`network` AS `network`,
        `item`.`vid` AS `vid`,
        `item`.`psid` AS `psid`,
-       `item`.`attach` AS `attach`,
-       (SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`) AS `internal-file-count`,
-       NULL AS `file`,
        IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
        `item-content`.`title` AS `title`,
        `item-content`.`content-warning` AS `content-warning`,
@@ -1631,6 +1643,7 @@ CREATE VIEW `post-view` AS SELECT
        `parent-item-author`.`name` AS `parent-author-name`,
        `parent-item-author`.`network` AS `parent-author-network`
        FROM `item`
+                       LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `item`.`uid`
                        STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                        STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
                        STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
@@ -1653,11 +1666,9 @@ CREATE VIEW `post-thread-view` AS SELECT
        `thread`.`iid` AS `iid`,
        `item`.`id` AS `item_id`,
        `thread`.`uid` AS `uid`,
-       `item`.`uid` AS `internal-uid`,
        `item`.`parent` AS `parent`,
        `item`.`uri` AS `uri`,
        `item`.`uri-id` AS `uri-id`,
-       `item`.`uri-id` AS `internal-uri-id`,
        `item`.`parent-uri` AS `parent-uri`,
        `item`.`parent-uri-id` AS `parent-uri-id`,
        `item`.`thr-parent` AS `thr-parent`,
@@ -1690,9 +1701,6 @@ CREATE VIEW `post-thread-view` AS SELECT
        `thread`.`network` AS `network`,
        `item`.`vid` AS `vid`,
        `item`.`psid` AS `psid`,
-       `item`.`attach` AS `attach`,
-       (SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`) AS `internal-file-count`,
-       NULL AS `file`,
        IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
        `item-content`.`title` AS `title`,
        `item-content`.`content-warning` AS `content-warning`,