3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * Automatic post-databse structure change updates
22 * These functions are responsible for doing critical post update changes to the data (not the structure) in the database.
24 * Database structure changes are done in static/dbstructure.config.php
26 * For non-critical database migrations, please add a method in the Database\PostUpdate class
28 * If there is a need for a post update to a structure change, update this file
29 * by adding a new function at the end with the number of the new DB_UPDATE_VERSION.
31 * The numbered script in this file has to be exactly like the DB_UPDATE_VERSION
34 * You are currently on version 4711 and you are preparing changes that demand an update script.
36 * 1. Create a function "update_4712()" here in the update.php
37 * 2. Apply the needed structural changes in static/dbStructure.php
38 * 3. Set DB_UPDATE_VERSION in static/dbstructure.config.php to 4712.
40 * If you need to run a script before the database update, name the function "pre_update_4712()"
43 use Friendica\Core\Addon;
44 use Friendica\Core\Logger;
45 use Friendica\Core\Update;
46 use Friendica\Core\Worker;
47 use Friendica\Database\DBA;
48 use Friendica\Database\DBStructure;
50 use Friendica\Model\Contact;
51 use Friendica\Model\Item;
52 use Friendica\Model\Photo;
53 use Friendica\Model\User;
54 use Friendica\Model\Storage;
55 use Friendica\Util\DateTimeFormat;
56 use Friendica\Worker\Delivery;
58 function update_1179()
60 if (DI::config()->get('system', 'no_community_page')) {
61 DI::config()->set('system', 'community_page_style', CP_NO_COMMUNITY_PAGE);
64 // Update the central item storage with uid=0
65 Worker::add(PRIORITY_LOW, "threadupdate");
67 return Update::SUCCESS;
70 function update_1181()
73 // Fill the new fields in the term table.
74 // deactivated, the "term" table is deprecated
75 // Worker::add(PRIORITY_LOW, "TagUpdate");
77 return Update::SUCCESS;
80 function update_1189()
83 if (strlen(DI::config()->get('system', 'directory_submit_url')) &&
84 !strlen(DI::config()->get('system', 'directory'))) {
85 DI::config()->set('system', 'directory', dirname(DI::config()->get('system', 'directory_submit_url')));
86 DI::config()->delete('system', 'directory_submit_url');
89 return Update::SUCCESS;
92 function update_1191()
94 DI::config()->set('system', 'maintenance', 1);
96 if (Addon::isEnabled('forumlist')) {
97 Addon::uninstall('forumlist');
100 // select old formlist addon entries
101 $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
102 DBA::escape('forumlist')
105 // convert old forumlist addon entries in new config entries
106 if (DBA::isResult($r)) {
107 foreach ($r as $rr) {
109 $family = $rr['cat'];
113 if ($key === 'randomise') {
114 DI::pConfig()->delete($uid, $family, $key);
117 if ($key === 'show_on_profile') {
119 DI::pConfig()->set($uid, 'feature', 'forumlist_profile', $value);
122 DI::pConfig()->delete($uid, $family, $key);
125 if ($key === 'show_on_network') {
127 DI::pConfig()->set($uid, 'feature', 'forumlist_widget', $value);
130 DI::pConfig()->delete($uid, $family, $key);
135 DI::config()->set('system', 'maintenance', 0);
137 return Update::SUCCESS;
140 function update_1203()
142 $r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
143 DBA::escape(User::ACCOUNT_TYPE_COMMUNITY),
144 DBA::escape(User::PAGE_FLAGS_COMMUNITY),
145 DBA::escape(User::PAGE_FLAGS_PRVGROUP)
149 function update_1244()
151 // Sets legacy_password for all legacy hashes
152 DBA::update('user', ['legacy_password' => true], ['SUBSTR(password, 1, 4) != "$2y$"']);
154 // All legacy hashes are re-hashed using the new secure hashing function
155 $stmt = DBA::select('user', ['uid', 'password'], ['legacy_password' => true]);
156 while ($user = DBA::fetch($stmt)) {
157 DBA::update('user', ['password' => User::hashPassword($user['password'])], ['uid' => $user['uid']]);
160 // Logged in users are forcibly logged out
161 DBA::delete('session', ['1 = 1']);
163 return Update::SUCCESS;
166 function update_1245()
168 $rino = DI::config()->get('system', 'rino_encrypt');
171 return Update::SUCCESS;
174 DI::config()->set('system', 'rino_encrypt', 1);
176 return Update::SUCCESS;
179 function update_1247()
181 // Removing hooks with the old name
182 DBA::e("DELETE FROM `hook`
183 WHERE `hook` LIKE 'plugin_%'");
185 // Make sure we install the new renamed ones
189 function update_1260()
191 DI::config()->set('system', 'maintenance', 1);
194 'maintenance_reason',
196 '%s: Updating author-id and owner-id in item and thread table. ',
197 DateTimeFormat::utcNow().' '.date('e')
201 $items = DBA::p("SELECT `id`, `owner-link`, `owner-name`, `owner-avatar`, `network` FROM `item`
202 WHERE `owner-id` = 0 AND `owner-link` != ''");
203 while ($item = DBA::fetch($items)) {
204 $contact = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
205 'photo' => $item['owner-avatar'], 'network' => $item['network']];
206 $cid = Contact::getIdForURL($item['owner-link'], 0, null, $contact);
210 Item::update(['owner-id' => $cid], ['id' => $item['id']]);
214 DBA::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id`
215 SET `thread`.`owner-id` = `item`.`owner-id` WHERE `thread`.`owner-id` = 0");
217 $items = DBA::p("SELECT `id`, `author-link`, `author-name`, `author-avatar`, `network` FROM `item`
218 WHERE `author-id` = 0 AND `author-link` != ''");
219 while ($item = DBA::fetch($items)) {
220 $contact = ['url' => $item['author-link'], 'name' => $item['author-name'],
221 'photo' => $item['author-avatar'], 'network' => $item['network']];
222 $cid = Contact::getIdForURL($item['author-link'], 0, null, $contact);
226 Item::update(['author-id' => $cid], ['id' => $item['id']]);
230 DBA::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id`
231 SET `thread`.`author-id` = `item`.`author-id` WHERE `thread`.`author-id` = 0");
233 DI::config()->set('system', 'maintenance', 0);
234 return Update::SUCCESS;
237 function update_1261()
239 // This fixes the results of an issue in the develop branch of 2018-05.
240 DBA::update('contact', ['blocked' => false, 'pending' => false], ['uid' => 0, 'blocked' => true, 'pending' => true]);
241 return Update::SUCCESS;
244 function update_1278()
246 DI::config()->set('system', 'maintenance', 1);
249 'maintenance_reason',
251 '%s: Updating post-type.',
252 DateTimeFormat::utcNow().' '.date('e')
256 Item::update(['post-type' => Item::PT_PAGE], ['bookmark' => true]);
257 Item::update(['post-type' => Item::PT_PERSONAL_NOTE], ['type' => 'note']);
259 DI::config()->set('system', 'maintenance', 0);
261 return Update::SUCCESS;
264 function update_1288()
266 // Updates missing `uri-id` values
268 DBA::e("UPDATE `item-activity` INNER JOIN `item` ON `item`.`iaid` = `item-activity`.`id` SET `item-activity`.`uri-id` = `item`.`uri-id` WHERE `item-activity`.`uri-id` IS NULL OR `item-activity`.`uri-id` = 0");
269 DBA::e("UPDATE `item-content` INNER JOIN `item` ON `item`.`icid` = `item-content`.`id` SET `item-content`.`uri-id` = `item`.`uri-id` WHERE `item-content`.`uri-id` IS NULL OR `item-content`.`uri-id` = 0");
271 return Update::SUCCESS;
274 // Post-update script of PR 5751
275 function update_1298()
277 $keys = ['gender', 'marital', 'sexual'];
278 foreach ($keys as $translateKey) {
279 $allData = DBA::select('profile', ['id', $translateKey]);
280 $allLangs = DI::l10n()->getAvailableLanguages();
283 foreach ($allData as $key => $data) {
284 $toTranslate = $data[$translateKey];
285 if ($toTranslate != '') {
286 foreach ($allLangs as $key => $lang) {
287 $a = new \stdClass();
290 // First we get the the localizations
291 if (file_exists("view/lang/$lang/strings.php")) {
292 include "view/lang/$lang/strings.php";
294 if (file_exists("addon/morechoice/lang/$lang/strings.php")) {
295 include "addon/morechoice/lang/$lang/strings.php";
298 $localizedStrings = $a->strings;
301 $key = array_search($toTranslate, $localizedStrings);
302 if ($key !== false) {
306 // defaulting to empty string
313 DBA::update('profile', [$translateKey => $key], ['id' => $data['id']]);
314 Logger::notice('Updated contact', ['action' => 'update', 'contact' => $data['id'], "$translateKey" => $key,
315 'was' => $data[$translateKey]]);
316 Worker::add(PRIORITY_LOW, 'ProfileUpdate', $data['id']);
317 Contact::updateSelfFromUserID($data['id']);
323 Logger::notice($translateKey . " fix completed", ['action' => 'update', 'translateKey' => $translateKey, 'Success' => $success, 'Fail' => $fail ]);
325 return Update::SUCCESS;
328 function update_1309()
330 $queue = DBA::select('queue', ['id', 'cid', 'guid']);
331 while ($entry = DBA::fetch($queue)) {
332 $contact = DBA::selectFirst('contact', ['uid'], ['id' => $entry['cid']]);
333 if (!DBA::isResult($contact)) {
337 $item = Item::selectFirst(['id', 'gravity'], ['uid' => $contact['uid'], 'guid' => $entry['guid']]);
338 if (!DBA::isResult($item)) {
342 $deliver_options = ['priority' => PRIORITY_MEDIUM, 'dont_fork' => true];
343 Worker::add($deliver_options, 'Delivery', Delivery::POST, $item['id'], $entry['cid']);
344 Logger::info('Added delivery worker', ['item' => $item['id'], 'contact' => $entry['cid']]);
345 DBA::delete('queue', ['id' => $entry['id']]);
347 return Update::SUCCESS;
350 function update_1315()
352 if (DBStructure::existsTable('item-delivery-data')) {
353 DBA::delete('item-delivery-data', ['postopts' => '', 'inform' => '', 'queue_count' => 0, 'queue_done' => 0]);
355 return Update::SUCCESS;
358 function update_1318()
360 DBA::update('profile', ['marital' => "In a relation"], ['marital' => "Unavailable"]);
361 DBA::update('profile', ['marital' => "Single"], ['marital' => "Available"]);
363 Worker::add(PRIORITY_LOW, 'ProfileUpdate');
364 return Update::SUCCESS;
367 function update_1323()
369 $users = DBA::select('user', ['uid']);
370 while ($user = DBA::fetch($users)) {
371 Contact::updateSelfFromUserID($user['uid']);
375 return Update::SUCCESS;
378 function update_1327()
380 $contacts = DBA::select('contact', ['uid', 'id', 'blocked', 'readonly'], ["`uid` != ? AND (`blocked` OR `readonly`) AND NOT `pending`", 0]);
381 while ($contact = DBA::fetch($contacts)) {
382 Contact\User::setBlocked($contact['id'], $contact['uid'], $contact['blocked']);
383 Contact\User::setIgnored($contact['id'], $contact['uid'], $contact['readonly']);
385 DBA::close($contacts);
387 return Update::SUCCESS;
390 function update_1330()
392 $currStorage = DI::config()->get('storage', 'class', '');
394 // set the name of the storage instead of the classpath as config
395 if (!empty($currStorage)) {
396 /** @var Storage\IStorage $currStorage */
397 if (!DI::config()->set('storage', 'name', $currStorage::getName())) {
398 return Update::FAILED;
401 // try to delete the class since it isn't needed. This won't work with config files
402 DI::config()->delete('storage', 'class');
405 // Update attachments and photos
406 if (!DBA::p("UPDATE `photo` SET `photo`.`backend-class` = SUBSTR(`photo`.`backend-class`, 25) WHERE `photo`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'") ||
407 !DBA::p("UPDATE `attach` SET `attach`.`backend-class` = SUBSTR(`attach`.`backend-class`, 25) WHERE `attach`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'")) {
408 return Update::FAILED;
411 return Update::SUCCESS;
414 function update_1332()
416 $condition = ["`is-default` IS NOT NULL"];
417 $profiles = DBA::select('profile', [], $condition);
419 while ($profile = DBA::fetch($profiles)) {
420 DI::profileField()->migrateFromLegacyProfile($profile);
422 DBA::close($profiles);
424 DBA::update('contact', ['profile-id' => null], ['`profile-id` IS NOT NULL']);
426 return Update::SUCCESS;
429 function update_1347()
431 foreach (Item::ACTIVITIES as $index => $activity) {
432 DBA::insert('verb', ['id' => $index + 1, 'name' => $activity], true);
435 return Update::SUCCESS;
438 function pre_update_1348()
440 if (!DBA::exists('contact', ['id' => 0])) {
441 DBA::insert('contact', ['nurl' => '']);
442 $lastid = DBA::lastInsertId();
444 DBA::update('contact', ['id' => 0], ['id' => $lastid]);
448 // The tables "permissionset" and "tag" could or could not exist during the update.
449 // This depends upon the previous version. Depending upon this situation we have to add
450 // the "0" values before adding the foreign keys - or after would be sufficient.
454 DBA::e("DELETE FROM `auth_codes` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
455 DBA::e("DELETE FROM `tokens` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
457 return Update::SUCCESS;
460 function update_1348()
462 // Insert a permissionset with id=0
463 // Inserting it without an ID and then changing the value to 0 tricks the auto increment
464 if (!DBA::exists('permissionset', ['id' => 0])) {
465 DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']);
466 $lastid = DBA::lastInsertId();
468 DBA::update('permissionset', ['id' => 0], ['id' => $lastid]);
472 if (!DBA::exists('tag', ['id' => 0])) {
473 DBA::insert('tag', ['name' => '']);
474 $lastid = DBA::lastInsertId();
476 DBA::update('tag', ['id' => 0], ['id' => $lastid]);
480 return Update::SUCCESS;
483 function update_1349()
486 foreach (Item::ACTIVITIES as $index => $activity) {
487 if (!DBA::exists('verb', ['id' => $index + 1, 'name' => $activity])) {
493 // The update failed - but it cannot be recovered, since the data doesn't match our expectation
494 // This means that we can't use this "shortcut" to fill the "vid" field and we have to rely upon
495 // the postupdate. This is not fatal, but means that it will take some longer time for the system
497 return Update::SUCCESS;
500 if (!DBA::e("UPDATE `item` INNER JOIN `item-activity` ON `item`.`uri-id` = `item-activity`.`uri-id`
501 SET `vid` = `item-activity`.`activity` + 1 WHERE `gravity` = ? AND (`vid` IS NULL OR `vid` = 0)", GRAVITY_ACTIVITY)) {
502 return Update::FAILED;
505 return Update::SUCCESS;
508 function update_1351()
510 if (!DBA::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id` SET `thread`.`uri-id` = `item`.`uri-id`")) {
511 return Update::FAILED;
514 return Update::SUCCESS;
517 function pre_update_1354()
519 if (DBStructure::existsColumn('contact', ['ffi_keyword_blacklist'])
520 && !DBStructure::existsColumn('contact', ['ffi_keyword_denylist'])
521 && !DBA::e("ALTER TABLE `contact` CHANGE `ffi_keyword_blacklist` `ffi_keyword_denylist` text null")) {
522 return Update::FAILED;
524 return Update::SUCCESS;
527 function update_1354()
529 if (DBStructure::existsColumn('contact', ['ffi_keyword_blacklist'])
530 && DBStructure::existsColumn('contact', ['ffi_keyword_denylist'])) {
531 if (!DBA::e("UPDATE `contact` SET `ffi_keyword_denylist` = `ffi_keyword_blacklist`")) {
532 return Update::FAILED;
535 // When the data had been copied then the main task is done.
536 // Having the old field removed is only beauty but not crucial.
537 // So we don't care if this was successful or not.
538 DBA::e("ALTER TABLE `contact` DROP `ffi_keyword_blacklist`");
540 return Update::SUCCESS;
543 function update_1357()
545 if (!DBA::e("UPDATE `contact` SET `failed` = true WHERE `success_update` < `failure_update` AND `failed` IS NULL")) {
546 return Update::FAILED;
549 if (!DBA::e("UPDATE `contact` SET `failed` = false WHERE `success_update` > `failure_update` AND `failed` IS NULL")) {
550 return Update::FAILED;
553 if (!DBA::e("UPDATE `contact` SET `failed` = false WHERE `updated` > `failure_update` AND `failed` IS NULL")) {
554 return Update::FAILED;
557 if (!DBA::e("UPDATE `contact` SET `failed` = false WHERE `last-item` > `failure_update` AND `failed` IS NULL")) {
558 return Update::FAILED;
561 if (!DBA::e("UPDATE `gserver` SET `failed` = true WHERE `last_contact` < `last_failure` AND `failed` IS NULL")) {
562 return Update::FAILED;
565 if (!DBA::e("UPDATE `gserver` SET `failed` = false WHERE `last_contact` > `last_failure` AND `failed` IS NULL")) {
566 return Update::FAILED;
569 return Update::SUCCESS;
572 function pre_update_1358()
574 if (!DBA::e("DELETE FROM `contact-relation` WHERE NOT `relation-cid` IN (SELECT `id` FROM `contact`) OR NOT `cid` IN (SELECT `id` FROM `contact`)")) {
575 return Update::FAILED;
578 return Update::SUCCESS;
581 function pre_update_1363()
583 Photo::delete(["`contact-id` != ? AND NOT `contact-id` IN (SELECT `id` FROM `contact`)", 0]);
584 return Update::SUCCESS;
587 function pre_update_1364()
589 if (!DBA::e("DELETE FROM `2fa_recovery_codes` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
590 return Update::FAILED;
593 if (!DBA::e("DELETE FROM `2fa_app_specific_password` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
594 return Update::FAILED;
597 if (!DBA::e("DELETE FROM `attach` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
598 return Update::FAILED;
601 if (!DBA::e("DELETE FROM `clients` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
602 return Update::FAILED;
605 if (!DBA::e("DELETE FROM `conv` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
606 return Update::FAILED;
609 if (!DBA::e("DELETE FROM `fsuggest` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
610 return Update::FAILED;
613 if (!DBA::e("DELETE FROM `group` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
614 return Update::FAILED;
617 if (!DBA::e("DELETE FROM `intro` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
618 return Update::FAILED;
621 if (!DBA::e("DELETE FROM `manage` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
622 return Update::FAILED;
625 if (!DBA::e("DELETE FROM `manage` WHERE NOT `mid` IN (SELECT `uid` FROM `user`)")) {
626 return Update::FAILED;
629 if (!DBA::e("DELETE FROM `mail` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
630 return Update::FAILED;
633 if (!DBA::e("DELETE FROM `mailacct` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
634 return Update::FAILED;
637 if (!DBA::e("DELETE FROM `notify` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
638 return Update::FAILED;
641 if (!DBA::e("DELETE FROM `openwebauth-token` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
642 return Update::FAILED;
645 if (!DBA::e("DELETE FROM `pconfig` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
646 return Update::FAILED;
649 if (!DBA::e("DELETE FROM `profile` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
650 return Update::FAILED;
653 if (!DBA::e("DELETE FROM `profile_check` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
654 return Update::FAILED;
657 if (!DBA::e("DELETE FROM `profile_field` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
658 return Update::FAILED;
661 if (!DBA::e("DELETE FROM `push_subscriber` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
662 return Update::FAILED;
665 if (!DBA::e("DELETE FROM `register` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
666 return Update::FAILED;
669 if (!DBA::e("DELETE FROM `search` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
670 return Update::FAILED;
673 if (!DBA::e("DELETE FROM `tokens` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
674 return Update::FAILED;
677 if (!DBA::e("DELETE FROM `user-contact` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
678 return Update::FAILED;
681 if (!DBA::e("DELETE FROM `user-item` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
682 return Update::FAILED;
685 if (!DBA::e("DELETE FROM `notify-threads` WHERE NOT `receiver-uid` IN (SELECT `uid` FROM `user`)")) {
686 return Update::FAILED;
689 if (!DBA::e("DELETE FROM `event` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
690 return Update::FAILED;
693 if (!DBA::e("DELETE FROM `fsuggest` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
694 return Update::FAILED;
697 if (!DBA::e("DELETE FROM `group_member` WHERE NOT `contact-id` IN (SELECT `id` FROM `contact`)")) {
698 return Update::FAILED;
701 if (!DBA::e("DELETE FROM `intro` WHERE NOT `contact-id` IN (SELECT `id` FROM `contact`)")) {
702 return Update::FAILED;
705 if (!DBA::e("DELETE FROM `participation` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
706 return Update::FAILED;
709 if (!DBA::e("DELETE FROM `profile_check` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
710 return Update::FAILED;
713 if (!DBA::e("DELETE FROM `user-contact` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
714 return Update::FAILED;
717 if (!DBA::e("DELETE FROM `participation` WHERE NOT `fid` IN (SELECT `id` FROM `fcontact`)")) {
718 return Update::FAILED;
721 if (!DBA::e("DELETE FROM `group_member` WHERE NOT `gid` IN (SELECT `id` FROM `group`)")) {
722 return Update::FAILED;
725 if (!DBA::e("DELETE FROM `gserver-tag` WHERE NOT `gserver-id` IN (SELECT `id` FROM `gserver`)")) {
726 return Update::FAILED;
729 if (!DBA::e("DELETE FROM `participation` WHERE NOT `iid` IN (SELECT `id` FROM `item`)")) {
730 return Update::FAILED;
733 if (!DBA::e("DELETE FROM `user-item` WHERE NOT `iid` IN (SELECT `id` FROM `item`)")) {
734 return Update::FAILED;
737 return Update::SUCCESS;
740 function pre_update_1365()
742 if (!DBA::e("DELETE FROM `notify-threads` WHERE NOT `notify-id` IN (SELECT `id` FROM `notify`)")) {
743 return Update::FAILED;
746 if (!DBA::e("DELETE FROM `thread` WHERE NOT `iid` IN (SELECT `id` FROM `item`)")) {
747 return Update::FAILED;