Ignore failures of collation change in the pre update step
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
d0a3d17912
commit
15bbe02106
|
@ -129,6 +129,7 @@ class Repair implements IOutput{
|
||||||
*/
|
*/
|
||||||
public static function getRepairSteps() {
|
public static function getRepairSteps() {
|
||||||
return [
|
return [
|
||||||
|
new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
|
||||||
new RepairMimeTypes(\OC::$server->getConfig()),
|
new RepairMimeTypes(\OC::$server->getConfig()),
|
||||||
new RepairLegacyStorages(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
|
new RepairLegacyStorages(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
|
||||||
new AssetCache(),
|
new AssetCache(),
|
||||||
|
@ -179,7 +180,7 @@ class Repair implements IOutput{
|
||||||
$connection = \OC::$server->getDatabaseConnection();
|
$connection = \OC::$server->getDatabaseConnection();
|
||||||
$steps = [
|
$steps = [
|
||||||
new InnoDB(),
|
new InnoDB(),
|
||||||
new Collation(\OC::$server->getConfig(), $connection),
|
new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
|
||||||
new SqliteAutoincrement($connection),
|
new SqliteAutoincrement($connection),
|
||||||
new SearchLuceneTables(),
|
new SearchLuceneTables(),
|
||||||
];
|
];
|
||||||
|
|
|
@ -24,28 +24,38 @@
|
||||||
|
|
||||||
namespace OC\Repair;
|
namespace OC\Repair;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Exception\DriverException;
|
||||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCP\IDBConnection;
|
||||||
|
use OCP\ILogger;
|
||||||
use OCP\Migration\IOutput;
|
use OCP\Migration\IOutput;
|
||||||
use OCP\Migration\IRepairStep;
|
use OCP\Migration\IRepairStep;
|
||||||
|
|
||||||
class Collation implements IRepairStep {
|
class Collation implements IRepairStep {
|
||||||
/**
|
/** @var IConfig */
|
||||||
* @var \OCP\IConfig
|
|
||||||
*/
|
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/**
|
/** @var ILogger */
|
||||||
* @var \OC\DB\Connection
|
protected $logger;
|
||||||
*/
|
|
||||||
|
/** @var IDBConnection */
|
||||||
protected $connection;
|
protected $connection;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
protected $ignoreFailures;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \OCP\IConfig $config
|
* @param IConfig $config
|
||||||
* @param \OC\DB\Connection $connection
|
* @param ILogger $logger
|
||||||
|
* @param IDBConnection $connection
|
||||||
|
* @param bool $ignoreFailures
|
||||||
*/
|
*/
|
||||||
public function __construct($config, $connection) {
|
public function __construct(IConfig $config, ILogger $logger, IDBConnection $connection, $ignoreFailures) {
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->ignoreFailures = $ignoreFailures;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
|
@ -67,7 +77,15 @@ class Collation implements IRepairStep {
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
$output->info("Change collation for $table ...");
|
$output->info("Change collation for $table ...");
|
||||||
$query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET ' . $characterSet . ' COLLATE ' . $characterSet . '_bin;');
|
$query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET ' . $characterSet . ' COLLATE ' . $characterSet . '_bin;');
|
||||||
$query->execute();
|
try {
|
||||||
|
$query->execute();
|
||||||
|
} catch (DriverException $e) {
|
||||||
|
// Just log this
|
||||||
|
$this->logger->logException($e);
|
||||||
|
if (!$this->ignoreFailures) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue