Skip to content

Commit 0ad4750

Browse files
committed
only check the changed tables for oracle compliance
this prevents a migration from being blocked by tables from a disabled app Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 49662f3 commit 0ad4750

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/private/DB/MigrationService.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525

2626
use Doctrine\DBAL\Platforms\OraclePlatform;
2727
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
28-
use Doctrine\DBAL\Schema\Column;
28+
use Doctrine\DBAL\Schema\Comparator;
2929
use Doctrine\DBAL\Schema\Index;
3030
use Doctrine\DBAL\Schema\Schema;
31+
use Doctrine\DBAL\Schema\SchemaDiff;
3132
use Doctrine\DBAL\Schema\SchemaException;
3233
use Doctrine\DBAL\Schema\Sequence;
3334
use OC\IntegrityCheck\Helpers\AppLocator;
@@ -457,7 +458,10 @@ public function executeStep($version, $schemaOnly = false) {
457458

458459
if ($toSchema instanceof SchemaWrapper) {
459460
$targetSchema = $toSchema->getWrappedSchema();
460-
$this->ensureOracleIdentifierLengthLimit($targetSchema, strlen($this->connection->getPrefix()));
461+
462+
$comparator = new Comparator();
463+
$diff = $comparator->compare($this->connection->createSchema(), $targetSchema);
464+
$this->ensureOracleIdentifierLengthLimit($diff, $targetSchema, strlen($this->connection->getPrefix()));
461465
$this->connection->migrateToSchema($targetSchema);
462466
$toSchema->performDropTableCalls();
463467
}
@@ -471,10 +475,13 @@ public function executeStep($version, $schemaOnly = false) {
471475
$this->markAsExecuted($version);
472476
}
473477

474-
public function ensureOracleIdentifierLengthLimit(Schema $schema, int $prefixLength) {
475-
$sequences = $schema->getSequences();
478+
public function ensureOracleIdentifierLengthLimit(SchemaDiff $schema, Schema $targetSchema, int $prefixLength) {
479+
$sequences = $schema->changedSequences;
476480

477-
foreach ($schema->getTables() as $table) {
481+
/** @var \Doctrine\DBAL\Schema\TableDiff[] $tables */
482+
$tables = array_merge($schema->changedTables, $schema->newTables);
483+
foreach ($tables as $tableDiff) {
484+
$table = $targetSchema->getTable($tableDiff->name);
478485
if (\strlen($table->getName()) - $prefixLength > 27) {
479486
throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.');
480487
}

0 commit comments

Comments
 (0)