Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-08-06 19:25:09 +0300
committerJoas Schilling <coding@schilljs.com>2018-12-17 15:52:08 +0300
commitf265657bc676272476f814d66c783560f139db02 (patch)
tree78f53fa5bcbe62efa2d3bac284e904c4dd9505b5 /lib/private/DB
parente7950a5bd6b8736f6fb16c67f2230b631806007b (diff)
Only check changed items
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/DB')
-rw-r--r--lib/private/DB/MigrationService.php31
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php
index f584cb351d2..62072accbc1 100644
--- a/lib/private/DB/MigrationService.php
+++ b/lib/private/DB/MigrationService.php
@@ -25,11 +25,11 @@ namespace OC\DB;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
-use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Sequence;
+use Doctrine\DBAL\Schema\Table;
use OC\IntegrityCheck\Helpers\AppLocator;
use OC\Migration\SimpleOutput;
use OCP\AppFramework\App;
@@ -456,9 +456,9 @@ class MigrationService {
}, ['tablePrefix' => $this->connection->getPrefix()]);
if ($toSchema instanceof SchemaWrapper) {
+ $sourceSchema = $this->connection->createSchema();
$targetSchema = $toSchema->getWrappedSchema();
- // TODO re-enable once stable14 is branched of: https://github.com/nextcloud/server/issues/10518
- // $this->ensureOracleIdentifierLengthLimit($targetSchema, strlen($this->connection->getPrefix()));
+ $this->ensureOracleIdentifierLengthLimit($sourceSchema, $targetSchema, strlen($this->connection->getPrefix()));
$this->connection->migrateToSchema($targetSchema);
$toSchema->performDropTableCalls();
}
@@ -472,34 +472,39 @@ class MigrationService {
$this->markAsExecuted($version);
}
- public function ensureOracleIdentifierLengthLimit(Schema $schema, int $prefixLength) {
- $sequences = $schema->getSequences();
+ public function ensureOracleIdentifierLengthLimit(Schema $sourceSchema, Schema $targetSchema, int $prefixLength) {
+ $sequences = $targetSchema->getSequences();
- foreach ($schema->getTables() as $table) {
- if (\strlen($table->getName()) - $prefixLength > 27) {
- throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.');
+ foreach ($targetSchema->getTables() as $table) {
+ try {
+ $sourceTable = $sourceSchema->getTable($table->getName());
+ } catch (SchemaException $e) {
+ if (\strlen($table->getName()) - $prefixLength > 27) {
+ throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.');
+ }
+ $sourceTable = null;
}
foreach ($table->getColumns() as $thing) {
- if (\strlen($thing->getName()) - $prefixLength > 27) {
+ if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && \strlen($thing->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
}
}
foreach ($table->getIndexes() as $thing) {
- if (\strlen($thing->getName()) - $prefixLength > 27) {
+ if ((!$sourceTable instanceof Table || !$sourceTable->hasIndex($thing->getName())) && \strlen($thing->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Index name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
}
}
foreach ($table->getForeignKeys() as $thing) {
- if (\strlen($thing->getName()) - $prefixLength > 27) {
+ if ((!$sourceTable instanceof Table || !$sourceTable->hasForeignKey($thing->getName())) && \strlen($thing->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Foreign key name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
}
}
$primaryKey = $table->getPrimaryKey();
- if ($primaryKey instanceof Index) {
+ if ($primaryKey instanceof Index && (!$sourceTable instanceof Table || !$sourceTable->hasPrimaryKey())) {
$indexName = strtolower($primaryKey->getName());
$isUsingDefaultName = $indexName === 'primary';
@@ -528,7 +533,7 @@ class MigrationService {
}
foreach ($sequences as $sequence) {
- if (\strlen($sequence->getName()) - $prefixLength > 27) {
+ if (!$sourceSchema->hasSequence($sequence->getName()) && \strlen($sequence->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.');
}
}