<?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 Version20190618064045 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_citydata (persistence_object_identifier VARCHAR(40) NOT NULL, city VARCHAR(40) DEFAULT NULL, zipcodes LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', idtoubiz VARCHAR(255) DEFAULT NULL, idtomas VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_56F8532D5B0234 (city), PRIMARY KEY(persistence_object_identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_citydata ADD CONSTRAINT FK_56F8532D5B0234 FOREIGN KEY (city) REFERENCES newland_toubiz_sync_neos_domain_model_article (persistence_object_identifier)');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_article ADD citydata VARCHAR(40) DEFAULT NULL');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_article ADD CONSTRAINT FK_2D54DF93CDAE9011 FOREIGN KEY (citydata) REFERENCES newland_toubiz_sync_neos_domain_model_citydata (persistence_object_identifier)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_2D54DF93CDAE9011 ON newland_toubiz_sync_neos_domain_model_article (citydata)');
    }

    /**
     * @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('ALTER TABLE newland_toubiz_sync_neos_domain_model_article DROP FOREIGN KEY FK_2D54DF93CDAE9011');
        $this->addSql('DROP TABLE newland_toubiz_sync_neos_domain_model_citydata');
        $this->addSql('DROP INDEX UNIQ_2D54DF93CDAE9011 ON newland_toubiz_sync_neos_domain_model_article');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_article DROP citydata');
    }
}
