2014-04-11 13:10:09 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OC\DB;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
|
2014-05-06 12:04:22 +00:00
|
|
|
class OracleMigrator extends NoCheckMigrator {
|
2014-04-11 13:10:09 +00:00
|
|
|
/**
|
|
|
|
* @param Schema $targetSchema
|
|
|
|
* @param \Doctrine\DBAL\Connection $connection
|
|
|
|
* @return \Doctrine\DBAL\Schema\SchemaDiff
|
|
|
|
*/
|
|
|
|
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
|
|
|
|
$schemaDiff = parent::getDiff($targetSchema, $connection);
|
|
|
|
|
|
|
|
// oracle forces us to quote the identifiers
|
|
|
|
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;
|
|
|
|
}
|
2014-06-03 09:24:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function generateTemporaryTableName($name) {
|
|
|
|
return 'oc_' . uniqid();
|
|
|
|
}
|
2013-10-17 18:16:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $statement
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function convertStatementToScript($statement) {
|
|
|
|
if (substr($statement, -1) === ';') {
|
|
|
|
return $statement . PHP_EOL . '/' . PHP_EOL;
|
|
|
|
}
|
|
|
|
$script = $statement . ';';
|
|
|
|
$script .= PHP_EOL;
|
|
|
|
$script .= PHP_EOL;
|
|
|
|
return $script;
|
|
|
|
}
|
2014-04-11 13:10:09 +00:00
|
|
|
}
|