diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-06-29 14:54:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-29 14:54:41 +0200 |
commit | b55ab6d22a82dbd5c1f6f30b23471dfb0a6a48ab (patch) | |
tree | 21451703ce0616984ebe66f22b7109ccb394b928 /lib/private/DB/Migrator.php | |
parent | c8fbe3980116bd94bd136c63d581c4bd6212cc3d (diff) | |
download | nextcloud-server-b55ab6d22a82dbd5c1f6f30b23471dfb0a6a48ab.tar.gz nextcloud-server-b55ab6d22a82dbd5c1f6f30b23471dfb0a6a48ab.zip |
Various database migration fixes (#25209)
* String columns with a length higher then 4000 are converted into a CLOB columns automagically - we have to respect this when migrating
* Adding schema migration tests to prevent unnecessary and non-sense migration steps
Fix Oracle autoincrement and unsigned handling
* Fix sqlite integer type for autoincrement
* Use lower case table names - fixes pg
* Fix postgres with default -1 - this only affect pg 9.4 servers - 9.5 seems to work fine
Diffstat (limited to 'lib/private/DB/Migrator.php')
-rw-r--r-- | lib/private/DB/Migrator.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/private/DB/Migrator.php b/lib/private/DB/Migrator.php index 8b8a34d9865..f2efd6916d7 100644 --- a/lib/private/DB/Migrator.php +++ b/lib/private/DB/Migrator.php @@ -33,6 +33,8 @@ use \Doctrine\DBAL\Schema\Table; use \Doctrine\DBAL\Schema\Schema; use \Doctrine\DBAL\Schema\SchemaConfig; use \Doctrine\DBAL\Schema\Comparator; +use Doctrine\DBAL\Types\StringType; +use Doctrine\DBAL\Types\Type; use OCP\IConfig; use OCP\Security\ISecureRandom; use Symfony\Component\EventDispatcher\EventDispatcher; @@ -194,7 +196,25 @@ class Migrator { return new Table($newName, $table->getColumns(), $newIndexes, array(), 0, $table->getOptions()); } + /** + * @param Schema $targetSchema + * @param \Doctrine\DBAL\Connection $connection + * @return \Doctrine\DBAL\Schema\SchemaDiff + * @throws DBALException + */ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { + // adjust varchar columns with a length higher then getVarcharMaxLength to clob + foreach ($targetSchema->getTables() as $table) { + foreach ($table->getColumns() as $column) { + if ($column->getType() instanceof StringType) { + if ($column->getLength() > $connection->getDatabasePlatform()->getVarcharMaxLength()) { + $column->setType(Type::getType('text')); + $column->setLength(null); + } + } + } + } + $filterExpression = $this->getFilterExpression(); $this->connection->getConfiguration()-> setFilterSchemaAssetsExpression($filterExpression); |