<?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 Version20190729212509 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
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\'.');
$this->addSql('ALTER TABLE customer ADD stage_previous_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE customer ADD CONSTRAINT FK_81398E09FC111FFA FOREIGN KEY (stage_previous_id) REFERENCES config_stage (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_81398E09FC111FFA ON customer (stage_previous_id)');
$this->addSql('UPDATE customer SET stage_previous_id = 2 WHERE stage_id = 3');
$this->addSql('UPDATE customer SET stage_previous_id = 3 WHERE stage_id = 4');
$this->addSql('UPDATE customer SET stage_previous_id = 4 WHERE stage_id = 5');
$this->addSql('UPDATE customer SET stage_previous_id = 5 WHERE stage_completed = 1');
}
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 DROP FOREIGN KEY FK_81398E09FC111FFA');
$this->addSql('DROP INDEX IDX_81398E09FC111FFA ON customer');
$this->addSql('ALTER TABLE customer DROP stage_previous_id');
}
}