Skip to content

Commit 9af5d4c

Browse files
committed
Only check the Oracle schema conditions if the app supports it
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 099381b commit 9af5d4c

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

lib/private/DB/MigrationService.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Doctrine\DBAL\Schema\SchemaException;
3131
use Doctrine\DBAL\Schema\Sequence;
3232
use Doctrine\DBAL\Schema\Table;
33+
use OC\App\InfoParser;
3334
use OC\IntegrityCheck\Helpers\AppLocator;
3435
use OC\Migration\SimpleOutput;
3536
use OCP\AppFramework\App;
@@ -51,6 +52,8 @@ class MigrationService {
5152
private $connection;
5253
/** @var string */
5354
private $appName;
55+
/** @var bool */
56+
private $checkOracle;
5457

5558
/**
5659
* MigrationService constructor.
@@ -72,6 +75,7 @@ public function __construct($appName, IDBConnection $connection, IOutput $output
7275
if ($appName === 'core') {
7376
$this->migrationsPath = \OC::$SERVERROOT . '/core/Migrations';
7477
$this->migrationsNamespace = 'OC\\Core\\Migrations';
78+
$this->checkOracle = true;
7579
} else {
7680
if (null === $appLocator) {
7781
$appLocator = new AppLocator();
@@ -80,6 +84,21 @@ public function __construct($appName, IDBConnection $connection, IOutput $output
8084
$namespace = App::buildAppNamespace($appName);
8185
$this->migrationsPath = "$appPath/lib/Migration";
8286
$this->migrationsNamespace = $namespace . '\\Migration';
87+
88+
$infoParser = new InfoParser();
89+
$info = $infoParser->parse($appPath . '/appinfo/info.xml');
90+
if (!isset($info['dependencies']['database'])) {
91+
$this->checkOracle = true;
92+
} else {
93+
$this->checkOracle = false;
94+
foreach ($info['dependencies']['database'] as $database) {
95+
if (\is_string($database) && $database === 'oci') {
96+
$this->checkOracle = true;
97+
} else if (\is_array($database) && isset($database['@value']) && $database['@value'] === 'oci') {
98+
$this->checkOracle = true;
99+
}
100+
}
101+
}
83102
}
84103
}
85104

@@ -456,9 +475,11 @@ public function executeStep($version, $schemaOnly = false) {
456475
}, ['tablePrefix' => $this->connection->getPrefix()]);
457476

458477
if ($toSchema instanceof SchemaWrapper) {
459-
$sourceSchema = $this->connection->createSchema();
460478
$targetSchema = $toSchema->getWrappedSchema();
461-
$this->ensureOracleIdentifierLengthLimit($sourceSchema, $targetSchema, strlen($this->connection->getPrefix()));
479+
if ($this->checkOracle) {
480+
$sourceSchema = $this->connection->createSchema();
481+
$this->ensureOracleIdentifierLengthLimit($sourceSchema, $targetSchema, strlen($this->connection->getPrefix()));
482+
}
462483
$this->connection->migrateToSchema($targetSchema);
463484
$toSchema->performDropTableCalls();
464485
}

0 commit comments

Comments
 (0)