From: Michael Date: Wed, 1 Apr 2020 18:11:06 +0000 (+0000) Subject: Check for Antelope and convert to Barracuda X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=01c6179feb8d8de25515858aaaf2c237031a7969;p=friendica.git Check for Antelope and convert to Barracuda --- diff --git a/src/Console/DatabaseStructure.php b/src/Console/DatabaseStructure.php index 62c8136406..6b1fa8d4d6 100644 --- a/src/Console/DatabaseStructure.php +++ b/src/Console/DatabaseStructure.php @@ -54,7 +54,7 @@ Commands dryrun Show database update schema queries without running them update Update database schema dumpsql Dump database schema - toinnodb Convert all tables from MyISAM to InnoDB + toinnodb Convert all tables from MyISAM or InnoDB in the Antelope file format to InnoDB in the Barracuda file format Options -h|--help|-? Show help information diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 06b6524944..6fe4d614d8 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -49,7 +49,7 @@ class DBStructure private static $definition = []; /** - * Converts all tables from MyISAM to InnoDB + * Converts all tables from MyISAM/InnoDB Antelope to InnoDB Barracuda */ public static function convertToInnoDB() { @@ -59,13 +59,19 @@ class DBStructure ['engine' => 'MyISAM', 'table_schema' => DBA::databaseName()] ); + $tables = array_merge($tables, DBA::selectToArray( + ['information_schema' => 'tables'], + ['table_name'], + ['engine' => 'InnoDB', 'ROW_FORMAT' => ['COMPACT', 'REDUNDANT'], 'table_schema' => DBA::databaseName()] + )); + if (!DBA::isResult($tables)) { - echo DI::l10n()->t('There are no tables on MyISAM.') . "\n"; + echo DI::l10n()->t('There are no tables on MyISAM or InnoDB with the Antelope file format.') . "\n"; return; } foreach ($tables AS $table) { - $sql = "ALTER TABLE " . DBA::quoteIdentifier($table['table_name']) . " engine=InnoDB;"; + $sql = "ALTER TABLE " . DBA::quoteIdentifier($table['table_name']) . " ENGINE=InnoDB ROW_FORMAT=DYNAMIC;"; echo $sql . "\n"; $result = DBA::e($sql); diff --git a/src/Model/Item.php b/src/Model/Item.php index 7ac1ab300a..a9a6eede23 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1957,7 +1957,7 @@ class Item // There are duplicates. We delete our just created entry. Logger::info('Delete duplicated item', ['id' => $current_post, 'uri' => $item['uri'], 'uid' => $item['uid'], 'guid' => $item['guid']]); - // Yes, we could do a rollback here - but we are having many users with MyISAM. + // Yes, we could do a rollback here - but we possibly are still having users with MyISAM. DBA::delete('item', ['id' => $current_post]); DBA::commit(); return 0; diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php index 7e3505e7ad..f676792d82 100644 --- a/src/Module/Admin/Summary.php +++ b/src/Module/Admin/Summary.php @@ -50,6 +50,11 @@ class Summary extends BaseAdmin $warningtext[] = DI::l10n()->t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See here for a guide that may be helpful converting the table engines. You may also use the command php bin/console.php dbstructure toinnodb of your Friendica installation for an automatic conversion.
', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html'); } + // are there InnoDB tables in Antelope in the DB? If so, trigger a warning message + if (DBA::count(['information_schema' => 'tables'], ['ENGINE' => 'InnoDB', 'ROW_FORMAT' => ['COMPACT', 'REDUNDANT'], 'table_schema' => DBA::databaseName()])) { + $warningtext[] = DI::l10n()->t('Your DB still runs with InnoDB tables in the Antelope file format. You should change the file format to Barracuda. Friendica is using features that are not provided by the Antelope format. See here for a guide that may be helpful converting the table engines. You may also use the command php bin/console.php dbstructure toinnodb of your Friendica installation for an automatic conversion.
', 'https://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html'); + } + // Check if github.com/friendica/master/VERSION is higher then // the local version of Friendica. Check is opt-in, source may be master or devel branch if (DI::config()->get('system', 'check_new_version_url', 'none') != 'none') {