]> git.mxchange.org Git - friendica.git/blobdiff - update.php
Most user-item traces removed
[friendica.git] / update.php
index 1d4fd38438d203b16592bf126e8f07a80cb9dc6b..05064d8e04072d482200db2f68bcaffae72bebc1 100644 (file)
@@ -266,6 +266,10 @@ function update_1348()
 
 function update_1349()
 {
+       if (!DBStructure::existsTable('item-activity')) {
+               return Update::SUCCESS;
+       }
+
        $correct = true;
        foreach (Item::ACTIVITIES as $index => $activity) {
                if (!DBA::exists('verb', ['id' => $index + 1, 'name' => $activity])) {
@@ -462,7 +466,7 @@ function pre_update_1364()
                return Update::FAILED;
        }
 
-       if (!DBA::e("DELETE FROM `user-item` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
+       if (DBStructure::existsTable('user-item') && !DBA::e("DELETE FROM `user-item` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
                return Update::FAILED;
        }
 
@@ -514,7 +518,7 @@ function pre_update_1364()
                return Update::FAILED;
        }
 
-       if (!DBA::e("DELETE FROM `user-item` WHERE NOT `iid` IN (SELECT `id` FROM `item`)")) {
+       if (DBStructure::existsTable('user-item') && !DBA::e("DELETE FROM `user-item` WHERE NOT `iid` IN (SELECT `id` FROM `item`)")) {
                return Update::FAILED;
        }
 
@@ -665,3 +669,63 @@ function update_1380()
 
        return Update::SUCCESS;
 }
+
+function pre_update_1395()
+{
+       if (DBStructure::existsTable('post-user') && !DBA::e("DROP TABLE `post-user`")) {
+               return Update::FAILED;
+       }
+       return Update::SUCCESS;
+}
+
+function update_1395()
+{
+       if (!DBA::e("INSERT INTO `post-user`(`id`, `uri-id`, `uid`, `contact-id`, `unseen`, `origin`, `psid`)
+               SELECT `id`, `uri-id`, `uid`, `contact-id`, `unseen`, `origin`, `psid` FROM `item`
+               ON DUPLICATE KEY UPDATE `contact-id` = `item`.`contact-id`, `unseen` = `item`.`unseen`, `origin` = `item`.`origin`, `psid` = `item`.`psid`")) {
+               return Update::FAILED;
+       }
+
+       if (DBStructure::existsTable('user-item') && !DBA::e("INSERT INTO `post-user`(`uri-id`, `uid`, `hidden`, `notification-type`)
+               SELECT `uri-id`, `user-item`.`uid`, `hidden`,`notification-type` FROM `user-item`
+                       INNER JOIN `item` ON `item`.`id` = `user-item`.`iid`
+               ON DUPLICATE KEY UPDATE `hidden` = `user-item`.`hidden`, `notification-type` = `user-item`.`notification-type`")) {
+               return Update::FAILED;
+       }
+       return Update::SUCCESS;
+}
+
+function update_1396()
+{
+       if (!DBStructure::existsTable('item-content')) {
+               return Update::SUCCESS;
+       }
+
+       if (!DBA::e("INSERT IGNORE INTO `post-content`(`uri-id`, `title`, `content-warning`, `body`, `raw-body`,
+               `location`, `coord`, `language`, `app`, `rendered-hash`, `rendered-html`,
+               `object-type`, `object`, `target-type`, `target`, `resource-id`, `plink`)
+               SELECT `item-content`.`uri-id`, `item-content`.`title`, `item-content`.`content-warning`,
+                       `item-content`.`body`, `item-content`.`raw-body`, `item-content`.`location`, `item-content`.`coord`,
+                       `item-content`.`language`, `item-content`.`app`, `item-content`.`rendered-hash`,
+                       `item-content`.`rendered-html`, `item-content`.`object-type`, `item-content`.`object`,
+                       `item-content`.`target-type`, `item-content`.`target`, `item`.`resource-id`, `item-content`.`plink`
+                       FROM `item-content` INNER JOIN `item` ON `item`.`uri-id` = `item-content`.`uri-id`")) {
+               return Update::FAILED;
+       }
+       return Update::SUCCESS;
+}
+
+function update_1397()
+{
+       if (!DBStructure::existsTable('thread') || !DBStructure::existsTable('user-item')) {
+               return Update::SUCCESS;
+       }
+
+       if (!DBA::e("INSERT IGNORE INTO `post-thread-user`(`uri-id`, `uid`, `pinned`, `starred`, `ignored`, `wall`, `pubmail`, `forum_mode`)
+               SELECT `thread`.`uri-id`, `thread`.`uid`, `user-item`.`pinned`, `thread`.`starred`,
+                       `thread`.`ignored`, `thread`.`wall`, `thread`.`pubmail`, `thread`.`forum_mode`
+               FROM `thread` LEFT JOIN `user-item` ON `user-item`.`iid` = `thread`.`iid`")) {
+               return Update::FAILED;
+       }
+       return Update::SUCCESS;
+}