<?php

namespace Application\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20170816215332 extends AbstractMigration
{
    /**
     * @param Schema $schema
     */
    public function up(Schema $schema)
    {
        // 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 operationpee ADD partner_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE operationpee ADD CONSTRAINT FK_2299D2B69393F8FE FOREIGN KEY (partner_id) REFERENCES establishment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_2299D2B69393F8FE ON operationpee (partner_id)');
    }

    /**
     * @param Schema $schema
     */
    public function down(Schema $schema)
    {
        // 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 OperationPEE DROP CONSTRAINT FK_2299D2B69393F8FE');
        $this->addSql('DROP INDEX IDX_2299D2B69393F8FE');
        $this->addSql('ALTER TABLE OperationPEE DROP partner_id');
    }
}
