<?php declare(strict_types=1);

namespace Application\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20190918132020 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 operationitdlc ADD CONSTRAINT FK_AC1535BD5BBA70BB FOREIGN KEY (prof) REFERENCES fos_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE demandepee ADD CONSTRAINT FK_B1B06105AC0F4BC4 FOREIGN KEY (operationpee) REFERENCES OperationPEE (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE demandepee ADD CONSTRAINT FK_B1B06105B467F3D5 FOREIGN KEY (cuser) REFERENCES fos_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE preference ADD CONSTRAINT FK_1234B383AA80356B FOREIGN KEY (selectedUser) REFERENCES fos_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE content ALTER metatitle TYPE TEXT');
        $this->addSql('ALTER TABLE content ALTER metatitle DROP DEFAULT');
        $this->addSql('ALTER TABLE sms_campaign ADD CONSTRAINT FK_79E333DCAC0F4BC4 FOREIGN KEY (operationpee) REFERENCES OperationPEE (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE fos_user ALTER is_available DROP DEFAULT');
        $this->addSql('ALTER TABLE operationpee_category ALTER is_active DROP DEFAULT');
        $this->addSql('ALTER TABLE operationpee_category ALTER is_active SET NOT NULL');
    }

    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('CREATE SCHEMA public');
        $this->addSql('ALTER TABLE sms_campaign DROP CONSTRAINT FK_79E333DCAC0F4BC4');
        $this->addSql('ALTER TABLE Content ALTER metatitle TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE Content ALTER metatitle DROP DEFAULT');
        $this->addSql('ALTER TABLE OperationITDLC DROP CONSTRAINT FK_AC1535BD5BBA70BB');
        $this->addSql('ALTER TABLE fos_user ALTER is_available SET DEFAULT \'true\'');
        $this->addSql('ALTER TABLE DemandePEE DROP CONSTRAINT FK_B1B06105AC0F4BC4');
        $this->addSql('ALTER TABLE DemandePEE DROP CONSTRAINT FK_B1B06105B467F3D5');
        $this->addSql('ALTER TABLE Preference DROP CONSTRAINT FK_1234B383AA80356B');
        $this->addSql('ALTER TABLE sms DROP CONSTRAINT FK_B0A93A77A76ED395');
        $this->addSql('ALTER TABLE sms ALTER sendinblue_api_return TYPE TEXT');
        $this->addSql('ALTER TABLE sms ALTER sendinblue_api_return DROP DEFAULT');
        $this->addSql('COMMENT ON COLUMN sms.sendinblue_api_return IS NULL');
        $this->addSql('ALTER TABLE operationpee_category ALTER is_active SET DEFAULT \'true\'');
        $this->addSql('ALTER TABLE operationpee_category ALTER is_active DROP NOT NULL');
    }
}
