2525
2626use Doctrine \DBAL \Platforms \OraclePlatform ;
2727use Doctrine \DBAL \Platforms \PostgreSqlPlatform ;
28- use Doctrine \DBAL \Schema \Column ;
28+ use Doctrine \DBAL \Schema \Comparator ;
2929use Doctrine \DBAL \Schema \Index ;
3030use Doctrine \DBAL \Schema \Schema ;
31+ use Doctrine \DBAL \Schema \SchemaDiff ;
3132use Doctrine \DBAL \Schema \SchemaException ;
3233use Doctrine \DBAL \Schema \Sequence ;
3334use 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