]> git.mxchange.org Git - friendica.git/blobdiff - update.php
Forgot one Logpoint ..
[friendica.git] / update.php
index e46a91107d044b188e61027e19204fd819b2242b..49287cd0b2a86205a9c944d4f36047fb4b0692bc 100644 (file)
@@ -240,9 +240,12 @@ function pre_update_1348()
 
        update_1348();
 
-       DBA::e("DELETE FROM `auth_codes` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
-       DBA::e("DELETE FROM `tokens` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
-
+       if (DBStructure::existsTable('auth_codes') && DBStructure::existsTable('clients')) {
+               DBA::e("DELETE FROM `auth_codes` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
+       }
+       if (DBStructure::existsTable('tokens') && DBStructure::existsTable('clients')) {
+               DBA::e("DELETE FROM `tokens` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
+       }
        return Update::SUCCESS;
 }
 
@@ -391,7 +394,7 @@ function pre_update_1364()
                return Update::FAILED;
        }
 
-       if (!DBA::e("DELETE FROM `clients` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
+       if (DBStructure::existsTable('clients') && !DBA::e("DELETE FROM `clients` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
                return Update::FAILED;
        }
 
@@ -443,7 +446,7 @@ function pre_update_1364()
                return Update::FAILED;
        }
 
-       if (!DBA::e("DELETE FROM `profile_check` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
+       if (DBStructure::existsTable('profile_check') && !DBA::e("DELETE FROM `profile_check` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
                return Update::FAILED;
        }
 
@@ -463,7 +466,7 @@ function pre_update_1364()
                return Update::FAILED;
        }
 
-       if (!DBA::e("DELETE FROM `tokens` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
+       if (DBStructure::existsTable('tokens') && !DBA::e("DELETE FROM `tokens` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
                return Update::FAILED;
        }
 
@@ -495,7 +498,7 @@ function pre_update_1364()
                return Update::FAILED;
        }
 
-       if (!DBA::e("DELETE FROM `profile_check` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
+       if (DBStructure::existsTable('profile_check') && !DBA::e("DELETE FROM `profile_check` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
                return Update::FAILED;
        }
 
@@ -694,16 +697,30 @@ function update_1396()
                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;
+       if (DBStructure::existsColumn('item-content', ['raw-body'])) {
+               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;
+               }
+       } else {
+               if (!DBA::e("INSERT IGNORE INTO `post-content`(`uri-id`, `title`, `content-warning`, `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`.`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;
 }
@@ -826,7 +843,7 @@ function update_1400()
 function pre_update_1403()
 {
        // Necessary before a primary key change
-       if (!DBA::e("DROP TABLE `parsed_url`")) {
+       if (DBStructure::existsTable('parsed_url') && !DBA::e("DROP TABLE `parsed_url`")) {
                return Update::FAILED;
        }
 
@@ -964,3 +981,28 @@ function update_1429()
 
        return Update::SUCCESS;
 }
+
+function update_1434()
+{
+       $name = DI::config()->get('storage', 'name');
+
+       // in case of an empty config, set "Database" as default storage backend
+       if (empty($name)) {
+               DI::config()->set('storage', 'name', Storage\Database::getName());
+       }
+
+       // In case of a Using deprecated storage class value, set the right name for it
+       if (stristr($name, 'Friendica\Model\Storage\\')) {
+               DI::config()->set('storage', 'name', substr($name, 24));
+       }
+
+       return Update::SUCCESS;
+}
+
+function update_1435()
+{
+       $contacts = DBA::select('contact', [], ["`uid` != ?", 0]);
+       while ($contact = DBA::fetch($contacts)) {
+               Contact\User::insertForContactArray($contact);
+       }
+}
\ No newline at end of file