Skip to content

Commit

Permalink
TASK: Fix MySQL migration differences on fresh setup
Browse files Browse the repository at this point in the history
Fixes neos#3118 (at least partly.)
  • Loading branch information
kdambekalns committed Apr 30, 2023
1 parent f2e3562 commit 9edfda4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Neos.ContentRepository/Migrations/Mysql/Version20230430183156.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);

namespace Neos\Flow\Persistence\Doctrine\Migrations;

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

/**
* Make index on movedto unique
*/
final class Version20230430183156 extends AbstractMigration
{
public function getDescription(): string
{
return 'Make index on movedto unique';
}

public function up(Schema $schema): void
{
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MysqlPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MysqlPlatform'."
);

$this->addSql('ALTER TABLE neos_contentrepository_domain_model_nodedata DROP INDEX IDX_CE6515692D45FE4D, ADD UNIQUE INDEX UNIQ_CE6515692D45FE4D (movedto)');
}

public function down(Schema $schema): void
{
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MysqlPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MysqlPlatform'."
);

$this->addSql('ALTER TABLE neos_contentrepository_domain_model_nodedata DROP INDEX UNIQ_CE6515692D45FE4D, ADD INDEX IDX_CE6515692D45FE4D (movedto)');
}
}
40 changes: 40 additions & 0 deletions Neos.Media/Migrations/Mysql/Version20230430183157.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);

namespace Neos\Flow\Persistence\Doctrine\Migrations;

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

/**
* Adjust key on Tag domain model to ON DELETE SET NULL
*/
final class Version20230430183157 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adjust key on Tag domain model to ON DELETE SET NULL';
}

public function up(Schema $schema): void
{
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MysqlPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MysqlPlatform'."
);

$this->addSql('ALTER TABLE neos_media_domain_model_tag DROP FOREIGN KEY FK_CA4889693D8E604F');
$this->addSql('ALTER TABLE neos_media_domain_model_tag ADD CONSTRAINT FK_CA4889693D8E604F FOREIGN KEY (parent) REFERENCES neos_media_domain_model_tag (persistence_object_identifier) ON DELETE SET NULL');
}

public function down(Schema $schema): void
{
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MysqlPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MysqlPlatform'."
);

$this->addSql('ALTER TABLE neos_media_domain_model_tag DROP FOREIGN KEY FK_CA4889693D8E604F');
$this->addSql('ALTER TABLE neos_media_domain_model_tag ADD CONSTRAINT FK_CA4889693D8E604F FOREIGN KEY (parent) REFERENCES neos_media_domain_model_tag (persistence_object_identifier)');
}
}

0 comments on commit 9edfda4

Please sign in to comment.