fix migration name and migrate old data

This commit is contained in:
Julien Fastré 2018-08-20 21:33:59 +02:00
parent baf4b1f277
commit 081f4f9b4c
2 changed files with 31 additions and 2 deletions

View File

@ -12,7 +12,6 @@ final class Version20180518144221 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() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_person_person ADD contactInfo TEXT DEFAULT NULL');
@ -22,7 +21,6 @@ final class Version20180518144221 extends AbstractMigration
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_person_person DROP contactInfo');

View File

@ -0,0 +1,31 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Correction: copie les infos de email vers contactInfo.
*
* Previously, data from contact where stored in 'email' column
*/
final class Version20180820120000 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('UPDATE chill_person_person SET contactInfo=email');
$this->addSql('UPDATE chill_person_person SET email=\'\'');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('UPDATE chill_person_person SET email=contactInfo');
$this->addSql('UPDATE chill_person_person SET contactInfo=\'\'');
}
}