<?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 Version20181012171813 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
// delete duplicate rows and keeping the lowest id
$this->addSql('DELETE t1 FROM customer_interview_form t1 INNER JOIN customer_interview_form t2 WHERE t1.id > t2.id AND t1.customer_id = t2.customer_id');
$this->addSql('ALTER TABLE customer_interview_form DROP INDEX IDX_20001B639395C3F3, ADD UNIQUE INDEX UNIQ_20001B639395C3F3 (customer_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE customer_interview_form DROP INDEX UNIQ_20001B639395C3F3, ADD INDEX IDX_20001B639395C3F3 (customer_id)');
}
}