Move 'addon' table into config

This commit is contained in:
Philipp 2023-01-03 19:54:05 +01:00
parent 6c033c9bd1
commit cd11088cc4
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
4 changed files with 22 additions and 4 deletions

View file

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2023.03-dev (Giant Rhubarb)
-- DB_UPDATE_VERSION 1508
-- DB_UPDATE_VERSION 1509
-- ------------------------------------------

View file

@ -74,7 +74,7 @@ class DBStructure
$old_tables = ['fserver', 'gcign', 'gcontact', 'gcontact-relation', 'gfollower' ,'glink', 'item-delivery-data',
'item-activity', 'item-content', 'item_id', 'participation', 'poll', 'poll_result', 'queue', 'retriever_rule',
'deliverq', 'dsprphotoq', 'ffinder', 'sign', 'spam', 'term', 'user-item', 'thread', 'item', 'challenge',
'auth_codes', 'tokens', 'clients', 'profile_check', 'host', 'conversation', 'fcontact', 'config'];
'auth_codes', 'tokens', 'clients', 'profile_check', 'host', 'conversation', 'fcontact', 'config', 'addon'];
$tables = DBA::selectToArray('INFORMATION_SCHEMA.TABLES', ['TABLE_NAME'],
['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']);

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1508);
define('DB_UPDATE_VERSION', 1509);
}
return [

View file

@ -1192,5 +1192,23 @@ function update_1508()
$newConfig->commit();
DBA::e("TRUNCATE TABLE `config`");
return DBA::e("TRUNCATE TABLE `config`") ? Update::SUCCESS : Update::FAILED;
}
function update_1509()
{
$addons = DBA::selectToArray('addon');
$newConfig = DI::config()->beginTransaction();
foreach ($addons as $addon) {
$newConfig->set('addons', $addon['name'], [
'last_update' => $addon['timestamp'],
'admin' => (bool)$addon['plugin_admin'],
]);
}
$newConfig->commit();
return DBA::e("TRUNCATE TABLE `addon`") ? Update::SUCCESS : Update::FAILED;
}