oraclemigrator.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. * @author Robin Appelman <icewind@owncloud.com>
  5. * @author Thomas Müller <thomas.mueller@tmit.eu>
  6. *
  7. * @copyright Copyright (c) 2015, ownCloud, Inc.
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OC\DB;
  24. use Doctrine\DBAL\Schema\Schema;
  25. class OracleMigrator extends NoCheckMigrator {
  26. /**
  27. * @param Schema $targetSchema
  28. * @param \Doctrine\DBAL\Connection $connection
  29. * @return \Doctrine\DBAL\Schema\SchemaDiff
  30. */
  31. protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
  32. $schemaDiff = parent::getDiff($targetSchema, $connection);
  33. // oracle forces us to quote the identifiers
  34. foreach ($schemaDiff->changedTables as $tableDiff) {
  35. $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
  36. foreach ($tableDiff->changedColumns as $column) {
  37. $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
  38. }
  39. }
  40. return $schemaDiff;
  41. }
  42. /**
  43. * @param string $name
  44. * @return string
  45. */
  46. protected function generateTemporaryTableName($name) {
  47. return 'oc_' . uniqid();
  48. }
  49. /**
  50. * @param $statement
  51. * @return string
  52. */
  53. protected function convertStatementToScript($statement) {
  54. if (substr($statement, -1) === ';') {
  55. return $statement . PHP_EOL . '/' . PHP_EOL;
  56. }
  57. $script = $statement . ';';
  58. $script .= PHP_EOL;
  59. $script .= PHP_EOL;
  60. return $script;
  61. }
  62. protected function getFilterExpression() {
  63. return '/^"' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
  64. }
  65. }