Skip to content

Commit

Permalink
Ignore automatic generated sequences
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 20, 2018
1 parent 575d6e2 commit a349ee0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/private/DB/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Sequence;
use OC\IntegrityCheck\Helpers\AppLocator;
use OC\Migration\SimpleOutput;
use OCP\AppFramework\App;
Expand Down Expand Up @@ -465,6 +466,8 @@ public function executeStep($version) {
}

public function ensureOracleIdentifierLengthLimit(Schema $schema) {
$sequences = $schema->getSequences();

foreach ($schema->getTables() as $table) {
if (\strlen($table->getName()) > 30) {
throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.');
Expand Down Expand Up @@ -496,6 +499,12 @@ public function ensureOracleIdentifierLengthLimit(Schema $schema) {
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
$defaultName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq';
$isUsingDefaultName = strtolower($defaultName) === $indexName;

if ($isUsingDefaultName) {
$sequences = array_filter($sequences, function(Sequence $sequence) use ($indexName) {
return $sequence->getName() !== $indexName;
});
}
} else if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$defaultName = $table->getName() . '_seq';
$isUsingDefaultName = strtolower($defaultName) === $indexName;
Expand All @@ -510,7 +519,7 @@ public function ensureOracleIdentifierLengthLimit(Schema $schema) {
}
}

foreach ($schema->getSequences() as $sequence) {
foreach ($sequences as $sequence) {
if (\strlen($sequence->getName()) > 30) {
throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.');
}
Expand Down

0 comments on commit a349ee0

Please sign in to comment.