<?php declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20180911204936 extends AbstractMigration
{
    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

        $this->addSql('ALTER TABLE fos_user ADD establishment_sector_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE fos_user DROP establishmentsector');
        $this->addSql('ALTER TABLE fos_user ADD CONSTRAINT FK_957A64791609E014 FOREIGN KEY (establishment_sector_id) REFERENCES operationpee_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_957A64791609E014 ON fos_user (establishment_sector_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() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

        
        $this->addSql('ALTER TABLE fos_user DROP CONSTRAINT FK_957A64791609E014');
        $this->addSql('DROP INDEX UNIQ_957A64791609E014');
        $this->addSql('ALTER TABLE fos_user ADD establishmentsector VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE fos_user DROP establishment_sector_id');
    }
}
