]> git.mxchange.org Git - friendica.git/blobdiff - update.php
Remove mod/subthread file
[friendica.git] / update.php
index 0a2f788f694697bc641a7f2d298510eb68898909..3e9292f2e43a85412afb0726ccb1be3ae0129d42 100644 (file)
@@ -40,7 +40,6 @@
  * If you need to run a script before the database update, name the function "pre_update_4712()"
  */
 
-use Friendica\Core\Addon;
 use Friendica\Core\Logger;
 use Friendica\Core\Update;
 use Friendica\Core\Worker;
@@ -50,7 +49,7 @@ use Friendica\Database\DBStructure;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
-use Friendica\Model\Notify;
+use Friendica\Model\Notification;
 use Friendica\Model\Photo;
 use Friendica\Model\Post;
 use Friendica\Model\Storage;
@@ -267,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])) {
@@ -655,14 +658,59 @@ function pre_update_1377()
 function update_1380()
 {
        if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`iid` SET `notify`.`uri-id` = `item`.`uri-id` WHERE `notify`.`uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
-               Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) {
+               Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
                return Update::FAILED;
        }
 
        if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`parent` SET `notify`.`parent-uri-id` = `item`.`uri-id` WHERE `notify`.`parent-uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
-               Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) {
+               Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
+               return Update::FAILED;
+       }
+
+       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 (!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;
+}
\ No newline at end of file