<?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 Version20191118184352 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('CREATE TABLE customer_phase (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, sort_order INT DEFAULT NULL, fault TINYINT(1) NOT NULL, INDEX idx_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE customer ADD phase_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE customer ADD CONSTRAINT FK_81398E0999091188 FOREIGN KEY (phase_id) REFERENCES customer_phase (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_81398E0999091188 ON customer (phase_id)');
$this->addSql('
INSERT INTO customer_phase (id, name, sort_order, fault)
VALUES
(1, \'Archive\', 1, 0),
(2, \'New\', 2, 1),
(3, \'Follow-up\', 3, 0),
(4, \'Interested\', 4, 0),
(5, \'Waiting\', 5, 0),
(6, \'Docs Signed\', 6, 0),
(7, \'Sold\', 7, 0)
');
$this->addSql('UPDATE customer SET phase_id = 2 WHERE status_id = 1'); // Interview
}
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_81398E0999091188');
$this->addSql('DROP TABLE customer_phase');
$this->addSql('DROP INDEX IDX_81398E0999091188 ON customer');
$this->addSql('ALTER TABLE customer DROP phase_id');
}
}