From 119de6467fd39938e79a7c96a16e25aba562172a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 31 Jan 2018 13:13:14 +0100 Subject: [PATCH] Create the migrations table also with the UTF8mb4 collation Signed-off-by: Joas Schilling --- lib/private/DB/MigrationService.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 5e2c7e69ee..9afe231b32 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -130,22 +130,20 @@ class MigrationService { // Drop the table, when it didn't match our expectations. $this->connection->dropTable('migrations'); + + // Recreate the schema after the table was dropped. + $schema = new SchemaWrapper($this->connection); + } catch (SchemaException $e) { // Table not found, no need to panic, we will create it. } - $tableName = $this->connection->getPrefix() . 'migrations'; - $tableName = $this->connection->getDatabasePlatform()->quoteIdentifier($tableName); + $table = $schema->createTable('migrations'); + $table->addColumn('app', Type::STRING, ['length' => 255]); + $table->addColumn('version', Type::STRING, ['length' => 255]); + $table->setPrimaryKey(['app', 'version']); - $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]), - ]; - $table = new Table($tableName, $columns); - $table->setPrimaryKey([ - $this->connection->getDatabasePlatform()->quoteIdentifier('app'), - $this->connection->getDatabasePlatform()->quoteIdentifier('version')]); - $this->connection->getSchemaManager()->createTable($table); + $this->connection->migrateToSchema($schema->getWrappedSchema()); $this->migrationTableCreated = true;