<?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 Version20190114205208 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 establishment ADD company_category_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE establishment ADD selectable_in_pee BOOLEAN DEFAULT \'true\'');
        $this->addSql('ALTER TABLE establishment ADD partner_category VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE establishment ADD display_in_front BOOLEAN DEFAULT \'false\'');
        $this->addSql('ALTER TABLE establishment ADD support_them BOOLEAN DEFAULT \'false\'');
        $this->addSql('ALTER TABLE establishment ADD support_us BOOLEAN DEFAULT \'true\'');
        $this->addSql('ALTER TABLE establishment ADD CONSTRAINT FK_DBEFB1EEB97257A FOREIGN KEY (company_category_id) REFERENCES operationpee_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_DBEFB1EEB97257A ON establishment (company_category_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 establishment DROP CONSTRAINT FK_DBEFB1EEB97257A');
        $this->addSql('DROP INDEX IDX_DBEFB1EEB97257A');
        $this->addSql('ALTER TABLE establishment DROP company_category_id');
        $this->addSql('ALTER TABLE establishment DROP selectable_in_pee');
        $this->addSql('ALTER TABLE establishment DROP partner_category');
        $this->addSql('ALTER TABLE establishment DROP display_in_front');
        $this->addSql('ALTER TABLE establishment DROP support_them');
        $this->addSql('ALTER TABLE establishment DROP support_us');
    }
}
