Skip to content

Commit

Permalink
Only check the Oracle schema conditions if the app supports it
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Aug 6, 2018
1 parent 5c38819 commit bba82f1
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lib/private/DB/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use OC\App\InfoParser;
use OC\IntegrityCheck\Helpers\AppLocator;
use OC\Migration\SimpleOutput;
use OCP\AppFramework\App;
Expand All @@ -51,6 +52,8 @@ class MigrationService {
private $connection;
/** @var string */
private $appName;
/** @var bool */
private $checkOracle;

/**
* MigrationService constructor.
Expand All @@ -72,6 +75,7 @@ public function __construct($appName, IDBConnection $connection, IOutput $output
if ($appName === 'core') {
$this->migrationsPath = \OC::$SERVERROOT . '/core/Migrations';
$this->migrationsNamespace = 'OC\\Core\\Migrations';
$this->checkOracle = true;
} else {
if (null === $appLocator) {
$appLocator = new AppLocator();
Expand All @@ -80,6 +84,21 @@ public function __construct($appName, IDBConnection $connection, IOutput $output
$namespace = App::buildAppNamespace($appName);
$this->migrationsPath = "$appPath/lib/Migration";
$this->migrationsNamespace = $namespace . '\\Migration';

$infoParser = new InfoParser();
$info = $infoParser->parse($appPath . '/appinfo/info.xml');
if (!isset($info['dependencies']['database'])) {
$this->checkOracle = true;
} else {
$this->checkOracle = false;
foreach ($info['dependencies']['database'] as $database) {
if (\is_string($database) && $database === 'oci') {
$this->checkOracle = true;
} else if (\is_array($database) && isset($database['@value']) && $database['@value'] === 'oci') {
$this->checkOracle = true;
}
}
}
}
}

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

if ($toSchema instanceof SchemaWrapper) {
$sourceSchema = $this->connection->createSchema();
$targetSchema = $toSchema->getWrappedSchema();
$this->ensureOracleIdentifierLengthLimit($sourceSchema, $targetSchema, strlen($this->connection->getPrefix()));
if ($this->checkOracle) {
$sourceSchema = $this->connection->createSchema();
$this->ensureOracleIdentifierLengthLimit($sourceSchema, $targetSchema, strlen($this->connection->getPrefix()));
}
$this->connection->migrateToSchema($targetSchema);
$toSchema->performDropTableCalls();
}
Expand Down

0 comments on commit bba82f1

Please sign in to comment.