<?php
namespace Neos\Flow\Persistence\Doctrine\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs! This block will be used as the migration description if getDescription() is not used.
 */
class Version20190829153604 extends AbstractMigration
{

    /**
     * @return string
     */
    public function getDescription()
    {
        return '';
    }

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

        $this->addSql('CREATE TABLE newland_toubiz_sync_neos_domain_model_article_locations_join (location CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', article CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', INDEX IDX_9D667DE5E9E89CB (location), INDEX IDX_9D667DE23A0E66 (article), PRIMARY KEY(location, article)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_article_locations_join ADD CONSTRAINT FK_9D667DE5E9E89CB FOREIGN KEY (location) REFERENCES newland_toubiz_sync_neos_domain_model_article (persistence_object_identifier)');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_article_locations_join ADD CONSTRAINT FK_9D667DE23A0E66 FOREIGN KEY (article) REFERENCES newland_toubiz_sync_neos_domain_model_article (persistence_object_identifier)');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_event ADD city CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:guid)\'');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_event ADD CONSTRAINT FK_4DAD30E62D5B0234 FOREIGN KEY (city) REFERENCES newland_toubiz_sync_neos_domain_model_article (persistence_object_identifier)');
        $this->addSql('CREATE INDEX IDX_4DAD30E62D5B0234 ON newland_toubiz_sync_neos_domain_model_event (city)');
    }

    /**
     * @param Schema $schema
     * @return void
     */
    public function down(Schema $schema)
    {
        // this down() migration is autogenerated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on "mysql".');

        $this->addSql('DROP TABLE newland_toubiz_sync_neos_domain_model_article_locations_join');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_event DROP FOREIGN KEY FK_4DAD30E62D5B0234');
        $this->addSql('DROP INDEX IDX_4DAD30E62D5B0234 ON newland_toubiz_sync_neos_domain_model_event');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_event DROP city');
    }
}
