diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-17 20:16:27 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-10-16 17:02:15 +0200 |
commit | f7097faf82604a6d8b89eed9d1d5ea3d0843e4f8 (patch) | |
tree | 384fc79ef0b77f7637ebea84604ae46b24807037 /lib/private/db/migrator.php | |
parent | 1ebeb6792eca53f34c2ad5a9c5eed7850b40fbb6 (diff) | |
download | nextcloud-server-f7097faf82604a6d8b89eed9d1d5ea3d0843e4f8.tar.gz nextcloud-server-f7097faf82604a6d8b89eed9d1d5ea3d0843e4f8.zip |
Special treatment for Oracle
Diffstat (limited to 'lib/private/db/migrator.php')
-rw-r--r-- | lib/private/db/migrator.php | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/private/db/migrator.php b/lib/private/db/migrator.php index d05f8455551..31c648a9b65 100644 --- a/lib/private/db/migrator.php +++ b/lib/private/db/migrator.php @@ -14,18 +14,27 @@ use \Doctrine\DBAL\Schema\Table; use \Doctrine\DBAL\Schema\Schema; use \Doctrine\DBAL\Schema\SchemaConfig; use \Doctrine\DBAL\Schema\Comparator; +use OCP\Security\ISecureRandom; class Migrator { + /** * @var \Doctrine\DBAL\Connection $connection */ protected $connection; /** + * @var ISecureRandom + */ + private $random; + + /** * @param \Doctrine\DBAL\Connection $connection + * @param ISecureRandom $random */ - public function __construct(\Doctrine\DBAL\Connection $connection) { + public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random) { $this->connection = $connection; + $this->random = $random; } /** @@ -45,8 +54,7 @@ class Migrator { $script = ''; $sqls = $schemaDiff->toSql($this->connection->getDatabasePlatform()); foreach ($sqls as $sql) { - $script .= $sql . ';'; - $script .= PHP_EOL; + $script .= $this->convertStatementToScript($sql); } return $script; @@ -84,7 +92,7 @@ class Migrator { * @return string */ protected function generateTemporaryTableName($name) { - return 'oc_' . $name . '_' . \OCP\Util::generateRandomBytes(13); + return 'oc_' . $name . '_' . $this->random->generate(13, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); } /** @@ -135,7 +143,7 @@ class Migrator { $indexName = $index->getName(); } else { // avoid conflicts in index names - $indexName = 'oc_' . \OCP\Util::generateRandomBytes(13); + $indexName = 'oc_' . $this->random->generate(13, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); } $newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary()); } @@ -201,4 +209,15 @@ class Migrator { protected function dropTable($name) { $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($name)); } + + /** + * @param $statement + * @return string + */ + protected function convertStatementToScript($statement) { + $script = $statement . ';'; + $script .= PHP_EOL; + $script .= PHP_EOL; + return $script; + } } |