]> git.mxchange.org Git - friendica.git/commitdiff
Added foreign key
authorMichael <heluecht@pirati.ca>
Tue, 22 Sep 2020 07:19:44 +0000 (07:19 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 22 Sep 2020 07:19:44 +0000 (07:19 +0000)
database.sql
src/Model/Item.php
src/Worker/MergeContact.php
static/dbstructure.config.php

index 499ac3b033a6914699f348f8b67604e65ae0d769..f598ab9ccb5363b9b5f5a7f0412766d41f7c25cd 100644 (file)
@@ -740,9 +740,11 @@ CREATE TABLE IF NOT EXISTS `item` (
         INDEX `uri-id` (`uri-id`),
         INDEX `parent-uri-id` (`parent-uri-id`),
         INDEX `thr-parent-id` (`thr-parent-id`),
+        INDEX `causer-id` (`causer-id`),
        FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
        FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
        FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+       FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
        FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
 
index 970c5f4a569149c8c010b7a6ab30a6ff4d0d8fd2..d03e9ec3547e00795fce16513c223ed70cdd8591 100644 (file)
@@ -775,7 +775,7 @@ class Item
                        }
                }
                if (strpos($sql_commands, "`causer`.") !== false) {
-                       $joins .= " LEFT JOIN `contact` AS `causer` ON `causer`.`id` = $master_table.`causer-id`";
+                       $joins .= " LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`";
                }
 
                if (strpos($sql_commands, "`group_member`.") !== false) {
index 3bb4e7e689930e3b0a36520e57421fe02238113e..e04dfb6ac880afdde105767f4a850445912e7882 100644 (file)
@@ -55,6 +55,7 @@ class MergeContact
                        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]);
                } else {
index 2e53649b97d535d50cbdb69a6f5dade2ab67f233..7e69ec034cf201aef76f3fe0b4aaec47d6ecaffe 100755 (executable)
@@ -722,7 +722,7 @@ return [
                        "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
                        "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the owner of this item"],
                        "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
-                       "causer-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the contact that caused the item creation"],
+                       "causer-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the contact that caused the item creation"],
                        "icid" => ["type" => "int unsigned", "relation" => ["item-content" => "id"], "comment" => "Id of the item-content table entry that contains the whole item content"],
                        "iaid" => ["type" => "int unsigned", "relation" => ["item-activity" => "id"], "comment" => "Id of the item-activity table entry that contains the activity data"],
                        "vid" => ["type" => "smallint unsigned", "relation" => ["verb" => "id"], "comment" => "Id of the verb table entry that contains the activity verbs"],
@@ -814,6 +814,7 @@ return [
                        "uri-id" => ["uri-id"],
                        "parent-uri-id" => ["parent-uri-id"],
                        "thr-parent-id" => ["thr-parent-id"],
+                       "causer-id" => ["causer-id"],
                ]
        ],
        "item-activity" => [