migrations/Version20181012171813.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20181012171813 extends AbstractMigration
  10. {
  11.     public function up(Schema $schema): void
  12.     {
  13.         // this up() migration is auto-generated, please modify it to your needs
  14.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  15.         // delete duplicate rows and keeping the lowest id
  16.         $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');
  17.         $this->addSql('ALTER TABLE customer_interview_form DROP INDEX IDX_20001B639395C3F3, ADD UNIQUE INDEX UNIQ_20001B639395C3F3 (customer_id)');
  18.     }
  19.     public function down(Schema $schema): void
  20.     {
  21.         // this down() migration is auto-generated, please modify it to your needs
  22.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  23.         $this->addSql('ALTER TABLE customer_interview_form DROP INDEX UNIQ_20001B639395C3F3, ADD INDEX IDX_20001B639395C3F3 (customer_id)');
  24.     }
  25. }