Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only check the Oracle schema conditions if the app supports it
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Dec 17, 2018
commit c09fa1ee65dc944a8e9c689a441da9c7a440dd02
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so by default we check always check oracle?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if the author did not define a db, you can install it on any. It a db is given the dependency check ensures it. So that mathes the logic here

} 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