Skip to content

Commit

Permalink
Create the migrations table also with the UTF8mb4 collation
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen authored and MorrisJobke committed Jan 31, 2018
1 parent bb7a2b2 commit 119de64
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/private/DB/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,20 @@ private function createMigrationTable() {

// 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);

$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);
$table = $schema->createTable('migrations');
$table->addColumn('app', Type::STRING, ['length' => 255]);
$table->addColumn('version', Type::STRING, ['length' => 255]);
$table->setPrimaryKey(['app', 'version']);

$this->connection->migrateToSchema($schema->getWrappedSchema());

$this->migrationTableCreated = true;

Expand Down

0 comments on commit 119de64

Please sign in to comment.