Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 27 additions & 0 deletions core/Migrations/Version20170605143658.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace OC\Migrations;

use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;

/**
* Updates the column lengths for the migrations table to reflect changes in its schema
*/
class Version20170605143658 implements ISchemaMigration {

public function changeSchema(Schema $schema, array $options) {
// Get the table
$prefix = $options['tablePrefix'];
$table = $schema->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);
}
}
6 changes: 4 additions & 2 deletions lib/private/DB/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down