<?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 Version20190905133210 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__0d687_starclassifications_join (neos_article CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', neos_starclassification CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', INDEX IDX_79C21A4061A7D39C (neos_article), INDEX IDX_79C21A405A578A26 (neos_starclassification), PRIMARY KEY(neos_article, neos_starclassification)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
        $this->addSql('CREATE TABLE newland_toubiz_sync_neos_domain_model_starclassification (persistence_object_identifier CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', value SMALLINT NOT NULL, label VARCHAR(255) NOT NULL, badgeurl VARCHAR(255) DEFAULT NULL, originalid VARCHAR(50) NOT NULL, language CHAR(2) DEFAULT NULL, PRIMARY KEY(persistence_object_identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain__0d687_starclassifications_join ADD CONSTRAINT FK_79C21A4061A7D39C FOREIGN KEY (neos_article) REFERENCES newland_toubiz_sync_neos_domain_model_article (persistence_object_identifier)');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain__0d687_starclassifications_join ADD CONSTRAINT FK_79C21A405A578A26 FOREIGN KEY (neos_starclassification) REFERENCES newland_toubiz_sync_neos_domain_model_starclassification (persistence_object_identifier)');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_article DROP starclassification');
    }

    /**
     * @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__0d687_starclassifications_join DROP FOREIGN KEY FK_79C21A405A578A26');
        $this->addSql('DROP TABLE newland_toubiz_sync_neos_domain__0d687_starclassifications_join');
        $this->addSql('DROP TABLE newland_toubiz_sync_neos_domain_model_starclassification');
        $this->addSql('ALTER TABLE newland_toubiz_sync_neos_domain_model_article ADD starclassification SMALLINT DEFAULT NULL');
    }
}
