<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20190726082045 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

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

        $this->addSql('ALTER TABLE campaign ADD latest_organic_overview_id INT DEFAULT NULL, ADD latest_page_speed_check_id INT DEFAULT NULL, ADD latest_robots_check_id INT DEFAULT NULL, ADD latest_sitemap_check_id INT DEFAULT NULL, ADD latest_uptime_check_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DD2818E724 FOREIGN KEY (latest_organic_overview_id) REFERENCES organic_overview_check (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DD418D4765 FOREIGN KEY (latest_page_speed_check_id) REFERENCES page_speed_check (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DDFE04F131 FOREIGN KEY (latest_robots_check_id) REFERENCES robots_check (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DDC0AD86B7 FOREIGN KEY (latest_sitemap_check_id) REFERENCES sitemap_check (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DD51F7A1B7 FOREIGN KEY (latest_uptime_check_id) REFERENCES uptime_check (id) ON DELETE SET NULL');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_1F1512DD2818E724 ON campaign (latest_organic_overview_id)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_1F1512DD418D4765 ON campaign (latest_page_speed_check_id)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_1F1512DDFE04F131 ON campaign (latest_robots_check_id)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_1F1512DDC0AD86B7 ON campaign (latest_sitemap_check_id)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_1F1512DD51F7A1B7 ON campaign (latest_uptime_check_id)');
        $this->addSql('ALTER TABLE campaign_keyword_check CHANGE google_ad_words_cpc google_ad_words_cpc DOUBLE PRECISION DEFAULT NULL, CHANGE monthly_searches monthly_searches INT DEFAULT 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() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DD2818E724');
        $this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DD418D4765');
        $this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DDFE04F131');
        $this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DDC0AD86B7');
        $this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DD51F7A1B7');
        $this->addSql('DROP INDEX UNIQ_1F1512DD2818E724 ON campaign');
        $this->addSql('DROP INDEX UNIQ_1F1512DD418D4765 ON campaign');
        $this->addSql('DROP INDEX UNIQ_1F1512DDFE04F131 ON campaign');
        $this->addSql('DROP INDEX UNIQ_1F1512DDC0AD86B7 ON campaign');
        $this->addSql('DROP INDEX UNIQ_1F1512DD51F7A1B7 ON campaign');
        $this->addSql('ALTER TABLE campaign DROP latest_organic_overview_id, DROP latest_page_speed_check_id, DROP latest_robots_check_id, DROP latest_sitemap_check_id, DROP latest_uptime_check_id');
        $this->addSql('ALTER TABLE campaign_keyword_check CHANGE google_ad_words_cpc google_ad_words_cpc DOUBLE PRECISION DEFAULT NULL, CHANGE monthly_searches monthly_searches INT DEFAULT NULL');
    }
}
