<?php

namespace Application\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20170816215303 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 DROP CONSTRAINT fk_2299d2b671976a61');
        $this->addSql('DROP INDEX idx_2299d2b671976a61');
        $this->addSql('ALTER TABLE operationpee ADD quote_author TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE operationpee ADD quote_author_job TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE operationpee ADD is_new BOOLEAN DEFAULT \'false\' NOT NULL');
        $this->addSql('ALTER TABLE operationpee DROP quote_author_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 ADD quote_author_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE OperationPEE DROP quote_author');
        $this->addSql('ALTER TABLE OperationPEE DROP quote_author_job');
        $this->addSql('ALTER TABLE OperationPEE DROP is_new');
        $this->addSql('ALTER TABLE OperationPEE ADD CONSTRAINT fk_2299d2b671976a61 FOREIGN KEY (quote_author_id) REFERENCES fos_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX idx_2299d2b671976a61 ON OperationPEE (quote_author_id)');
    }
}
