<?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 Version20190206155738 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 adherent ADD groupe_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE adherent ADD CONSTRAINT FK_90D3F0607A45358C FOREIGN KEY (groupe_id) REFERENCES groupe (id)');
        $this->addSql('CREATE INDEX IDX_90D3F0607A45358C ON adherent (groupe_id)');
        $this->addSql('ALTER TABLE prestataire DROP FOREIGN KEY FK_60A264803AA0FF34');
        $this->addSql('DROP INDEX IDX_60A264803AA0FF34 ON prestataire');
        $this->addSql('ALTER TABLE prestataire CHANGE prestataire_group_id groupe_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE prestataire ADD CONSTRAINT FK_60A264807A45358C FOREIGN KEY (groupe_id) REFERENCES groupe (id)');
        $this->addSql('CREATE INDEX IDX_60A264807A45358C ON prestataire (groupe_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 adherent DROP FOREIGN KEY FK_90D3F0607A45358C');
        $this->addSql('DROP INDEX IDX_90D3F0607A45358C ON adherent');
        $this->addSql('ALTER TABLE adherent DROP groupe_id');
        $this->addSql('ALTER TABLE prestataire DROP FOREIGN KEY FK_60A264807A45358C');
        $this->addSql('DROP INDEX IDX_60A264807A45358C ON prestataire');
        $this->addSql('ALTER TABLE prestataire CHANGE groupe_id prestataire_group_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE prestataire ADD CONSTRAINT FK_60A264803AA0FF34 FOREIGN KEY (prestataire_group_id) REFERENCES groupe (id)');
        $this->addSql('CREATE INDEX IDX_60A264803AA0FF34 ON prestataire (prestataire_group_id)');
    }
}