2014-05-06 16:46:59 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2015-02-26 13:37:37 +03:00
|
|
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
2014-05-06 16:46:59 +04:00
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2014-05-06 16:46:59 +04:00
|
|
|
namespace OC\DB;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
|
|
|
|
class MySQLMigrator extends Migrator {
|
|
|
|
/**
|
|
|
|
* @param Schema $targetSchema
|
|
|
|
* @param \Doctrine\DBAL\Connection $connection
|
|
|
|
* @return \Doctrine\DBAL\Schema\SchemaDiff
|
|
|
|
*/
|
|
|
|
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
|
2014-07-24 14:17:26 +04:00
|
|
|
$platform = $connection->getDatabasePlatform();
|
|
|
|
$platform->registerDoctrineTypeMapping('enum', 'string');
|
|
|
|
$platform->registerDoctrineTypeMapping('bit', 'string');
|
|
|
|
|
2014-05-06 16:46:59 +04:00
|
|
|
$schemaDiff = parent::getDiff($targetSchema, $connection);
|
|
|
|
|
|
|
|
// identifiers need to be quoted for mysql
|
|
|
|
foreach ($schemaDiff->changedTables as $tableDiff) {
|
|
|
|
$tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
|
|
|
|
foreach ($tableDiff->changedColumns as $column) {
|
|
|
|
$column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $schemaDiff;
|
|
|
|
}
|
|
|
|
}
|