Skip to content

Commit

Permalink
Remove migrations, add new. Remove server version from doctrine config.
Browse files Browse the repository at this point in the history
Since there was server version inside config set to 5.7, migration:diss was always generating difference for some fields.
Known bug in dbal/doctrine - doctrine/orm#6565
  • Loading branch information
flackovic committed Sep 19, 2018
1 parent 9887eaf commit bd9809c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
1 change: 0 additions & 1 deletion config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
Expand Down
35 changes: 0 additions & 35 deletions src/Migrations/Version20180913195638.php

This file was deleted.

40 changes: 40 additions & 0 deletions src/Migrations/Version20180919182714.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180919182714 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE TABLE player_rating (id INT AUTO_INCREMENT NOT NULL, player_id INT NOT NULL, value INT NOT NULL, updated_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_4789B0FC99E6F5DF (player_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE `match` (id INT AUTO_INCREMENT NOT NULL, player_one_id INT NOT NULL, player_two_id INT NOT NULL, winner_id INT DEFAULT NULL, player_one_score INT NOT NULL, player_two_score INT NOT NULL, started_at DATETIME NOT NULL, ended_at DATETIME NOT NULL, INDEX IDX_7A5BC505649A58CD (player_one_id), INDEX IDX_7A5BC505FC6BF02 (player_two_id), INDEX IDX_7A5BC5055DFCD4B8 (winner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE player_rating ADD CONSTRAINT FK_4789B0FC99E6F5DF FOREIGN KEY (player_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE `match` ADD CONSTRAINT FK_7A5BC505649A58CD FOREIGN KEY (player_one_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE `match` ADD CONSTRAINT FK_7A5BC505FC6BF02 FOREIGN KEY (player_two_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE `match` ADD CONSTRAINT FK_7A5BC5055DFCD4B8 FOREIGN KEY (winner_id) REFERENCES user (id)');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE player_rating DROP FOREIGN KEY FK_4789B0FC99E6F5DF');
$this->addSql('ALTER TABLE `match` DROP FOREIGN KEY FK_7A5BC505649A58CD');
$this->addSql('ALTER TABLE `match` DROP FOREIGN KEY FK_7A5BC505FC6BF02');
$this->addSql('ALTER TABLE `match` DROP FOREIGN KEY FK_7A5BC5055DFCD4B8');
$this->addSql('DROP TABLE player_rating');
$this->addSql('DROP TABLE user');
$this->addSql('DROP TABLE `match`');
}
}

0 comments on commit bd9809c

Please sign in to comment.