Ignore automatic generated sequences

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-07-20 12:31:52 +02:00
parent 960961148e
commit 5e0bfe5c16
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 10 additions and 1 deletions

View File

@ -29,6 +29,7 @@ use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Sequence;
use OC\IntegrityCheck\Helpers\AppLocator; use OC\IntegrityCheck\Helpers\AppLocator;
use OC\Migration\SimpleOutput; use OC\Migration\SimpleOutput;
use OCP\AppFramework\App; use OCP\AppFramework\App;
@ -471,6 +472,8 @@ class MigrationService {
} }
public function ensureOracleIdentifierLengthLimit(Schema $schema) { public function ensureOracleIdentifierLengthLimit(Schema $schema) {
$sequences = $schema->getSequences();
foreach ($schema->getTables() as $table) { foreach ($schema->getTables() as $table) {
if (\strlen($table->getName()) > 30) { if (\strlen($table->getName()) > 30) {
throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.'); throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.');
@ -502,6 +505,12 @@ class MigrationService {
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) { if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
$defaultName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq'; $defaultName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq';
$isUsingDefaultName = strtolower($defaultName) === $indexName; $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) { } else if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$defaultName = $table->getName() . '_seq'; $defaultName = $table->getName() . '_seq';
$isUsingDefaultName = strtolower($defaultName) === $indexName; $isUsingDefaultName = strtolower($defaultName) === $indexName;
@ -516,7 +525,7 @@ class MigrationService {
} }
} }
foreach ($schema->getSequences() as $sequence) { foreach ($sequences as $sequence) {
if (\strlen($sequence->getName()) > 30) { if (\strlen($sequence->getName()) > 30) {
throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.'); throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.');
} }