From 187728533dab3f52212c880d86ad49b33210e9bd Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 5 Jun 2017 16:44:51 +0200 Subject: [PATCH] Fix column lengths on migrations table to fix index --- core/Migrations/Version20170605143658.php | 27 +++++++++++++++++++++++ lib/private/DB/MigrationService.php | 6 +++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 core/Migrations/Version20170605143658.php diff --git a/core/Migrations/Version20170605143658.php b/core/Migrations/Version20170605143658.php new file mode 100644 index 000000000000..c750eeb943f1 --- /dev/null +++ b/core/Migrations/Version20170605143658.php @@ -0,0 +1,27 @@ +getTable("{$prefix}migrations"); + + // Check column length to see if migration is necessary necessary + if($table->getColumn('app')->getLength() === 177) { + // then this server was installed after the fix + return; + } + + // Need to shorten columns + $table->getColumn('app')->setLength(177); + $table->getColumn('version')->setLength(14); + } +} diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index d38faa0443c6..b0ba9b64b6f5 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -114,8 +114,10 @@ private function createMigrationTable() { $tableName = $this->connection->getDatabasePlatform()->quoteIdentifier($tableName); $columns = [ - 'app' => new Column($this->connection->getDatabasePlatform()->quoteIdentifier('app'), Type::getType('string'), ['length' => 255]), - 'version' => new Column($this->connection->getDatabasePlatform()->quoteIdentifier('version'), Type::getType('string'), ['length' => 255]), + // Length = max indexable char length - length of other columns = 191 - 14 + 'app' => new Column($this->connection->getDatabasePlatform()->quoteIdentifier('app'), Type::getType('string'), ['length' => 177]), + // Datetime string. Eg: 20172605104128 + 'version' => new Column($this->connection->getDatabasePlatform()->quoteIdentifier('version'), Type::getType('string'), ['length' => 14]), ]; $table = new Table($tableName, $columns); $table->setPrimaryKey([