Version20190218154011.php 1.87 KB
<?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 Version20190218154011 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($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('ALTER TABLE user ADD gestionnaire_groupe_id INT DEFAULT NULL, ADD gestionnaire_comptoir_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D64929D29E4D FOREIGN KEY (gestionnaire_groupe_id) REFERENCES groupe (id)');
        $this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6493D550E0D FOREIGN KEY (gestionnaire_comptoir_id) REFERENCES comptoir (id)');
        $this->addSql('CREATE INDEX IDX_8D93D64929D29E4D ON user (gestionnaire_groupe_id)');
        $this->addSql('CREATE INDEX IDX_8D93D6493D550E0D ON user (gestionnaire_comptoir_id)');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D64929D29E4D');
        $this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6493D550E0D');
        $this->addSql('DROP INDEX IDX_8D93D64929D29E4D ON user');
        $this->addSql('DROP INDEX IDX_8D93D6493D550E0D ON user');
        $this->addSql('ALTER TABLE user DROP gestionnaire_groupe_id, DROP gestionnaire_comptoir_id');
    }
}