Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Remove duplicate index #27

Merged
merged 4 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Classes/Domain/Model/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* @Flow\Entity
* @ORM\Table(
* indexes={
* @ORM\Index(name="sourceuripathhash",columns={"sourceuripathhash","host"}),
* @ORM\Index(name="targeturipathhash",columns={"targeturipathhash","host"})
* }
* )
Expand Down Expand Up @@ -177,8 +176,7 @@ public function __construct(
$this->host = $host ? trim($host) : null;
$this->creator = $creator;
$this->comment = $comment;
$this->type = in_array($type,
[self::REDIRECT_TYPE_GENERATED, self::REDIRECT_TYPE_MANUAL]) ? $type : self::REDIRECT_TYPE_GENERATED;
$this->type = in_array($type, [self::REDIRECT_TYPE_GENERATED, self::REDIRECT_TYPE_MANUAL]) ? $type : self::REDIRECT_TYPE_GENERATED;
$this->startDateTime = $startDateTime;
$this->endDateTime = $endDateTime;

Expand Down
36 changes: 36 additions & 0 deletions Migrations/Mysql/Version20220912100052.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Neos\Flow\Persistence\Doctrine\Migrations;

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

final class Version20220912100052 extends AbstractMigration
{
public function getDescription(): string
{
return 'Removes a duplicate index';
}

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('DROP INDEX sourceuripathhash ON neos_redirecthandler_databasestorage_domain_model_redirect');
}

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('CREATE INDEX sourceuripathhash ON neos_redirecthandler_databasestorage_domain_model_redirect (sourceuripathhash, host)');
}
}
40 changes: 40 additions & 0 deletions Migrations/Postgresql/Version20220912204346.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;

class Version20220912204346 extends AbstractMigration
{
public function getDescription(): string
{
return 'Removes a duplicate index';
}

/**
* @param Schema $schema
* @return void
*/
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on "postgresql".');

$this->addSql('DROP INDEX sourceuripathhash');

}

/**
* @param Schema $schema
* @return void
*/
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on "postgresql".');

$this->addSql('CREATE INDEX sourceuripathhash ON neos_redirecthandler_databasestorage_domain_model_redirect (sourceuripathhash, host)');

}
}