]> git.mxchange.org Git - friendica.git/commitdiff
Fix "Cannot drop index 'last-editor-uid': needed in a foreign key constraint"
authorMichael <heluecht@pirati.ca>
Mon, 10 Jul 2023 20:50:16 +0000 (20:50 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 10 Jul 2023 20:50:16 +0000 (20:50 +0000)
database.sql
doc/database/db_report.md
static/dbstructure.config.php
static/dbview.config.php

index 5b6f1695c389c0c3bdc3cd933349e87ba9bcb5ea..13158d1eaa9cac38fe9754ab9389d7c376192978 100644 (file)
@@ -1712,6 +1712,7 @@ CREATE TABLE IF NOT EXISTS `report` (
         INDEX `cid` (`cid`),
         INDEX `reporter-id` (`reporter-id`),
         INDEX `gsid` (`gsid`),
+        INDEX `last-editor-uid` (`last-editor-uid`),
         INDEX `assigned-uid` (`assigned-uid`),
         INDEX `status-resolution` (`status`,`resolution`),
         INDEX `created` (`created`),
@@ -2635,13 +2636,15 @@ CREATE VIEW `network-item-view` AS SELECT
        `ownercontact`.`contact-type` AS `contact-type`
        FROM `post-user`
                        INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`                     
-                       INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
+                       STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
+                       STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
+                       STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
                        LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
-                       INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
                        AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
                        AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
+                       AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
                        AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
                        AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
 
@@ -2664,12 +2667,14 @@ CREATE VIEW `network-thread-view` AS SELECT
        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`
+                       STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
+                       STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
                        LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
-                       LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
                        AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
                        AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
+                       AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
                        AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
                        AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
 
index cb2bcb1895cddf01f46d38bb03d033665c654978..d143839990d4dd149d9eda89469f48b98ed9c7d7 100644 (file)
@@ -35,6 +35,7 @@ Indexes
 | cid               | cid                |
 | reporter-id       | reporter-id        |
 | gsid              | gsid               |
+| last-editor-uid   | last-editor-uid    |
 | assigned-uid      | assigned-uid       |
 | status-resolution | status, resolution |
 | created           | created            |
index 33cf1d86ad98a3932e0a91088f3780494ffe94db..303e42e035b66fadfaf3c8edaf2793931d133fdf 100644 (file)
@@ -1710,6 +1710,7 @@ return [
                        "cid" => ["cid"],
                        "reporter-id" => ["reporter-id"],
                        "gsid" => ["gsid"],
+                       "last-editor-uid" => ["last-editor-uid"],
                        "assigned-uid" => ["assigned-uid"],
                        "status-resolution" => ["status", "resolution"],
                        "created" => ["created"],
index 004063a4185d293e0a3eac4547fdc4cb2ccd6e66..43959f363361e9b4cc907689c70540cfd724c93b 100644 (file)
                ],
                "query" => "FROM `post-user`
                        INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`                     
-                       INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
+                       STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
+                       STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
+                       STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
                        LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
-                       INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
                        AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
                        AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
+                       AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
                        AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
                        AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
        ],
                "query" => "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`
+                       STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
+                       STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
                        LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
-                       LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
                        WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
                        AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
                        AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
+                       AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
                        AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
                        AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
        ],