Skip to content

Commit 7024aa8

Browse files
committed
Remove consent.deleted_at index
Prior to this change, consent had an unused index that was not present in the production database. This change removes the unused index from the mapping. If this index is present in the database, it will remove it. The deleted_at index is never used on its own. The queries are filtered first on hashed_user_id, after that, the index adds nothing. #1906
1 parent 613e9d1 commit 7024aa8

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OpenConext\EngineBlock\Doctrine\Migrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Patch/repair migration - Removes the deleted_at index from the consent table if present.
12+
*
13+
* On existing databases where the index is already absent this migration is marked as done
14+
* without executing any SQL. On databases where the index still exists it will be dropped.
15+
*/
16+
final class Version20260224000000 extends AbstractMigration
17+
{
18+
public function getDescription(): string
19+
{
20+
return 'Patch migration: Removes the deleted_at index from the consent table. Skips if the index does not exist.';
21+
}
22+
23+
public function preUp(Schema $schema): void
24+
{
25+
$indexes = $this->connection->createSchemaManager()->listTableIndexes('consent');
26+
$this->skipIf(
27+
!isset($indexes['deleted_at']),
28+
'Index deleted_at on consent table does not exist. Skipping.'
29+
);
30+
}
31+
32+
public function up(Schema $schema): void
33+
{
34+
$this->addSql('ALTER TABLE `consent` DROP INDEX `deleted_at`');
35+
}
36+
37+
}

src/OpenConext/EngineBlockBundle/Authentication/Entity/Consent.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#[ORM\Entity]
3232
#[ORM\Index(name: 'hashed_user_id', columns: ['hashed_user_id'])]
3333
#[ORM\Index(name: 'service_id', columns: ['service_id'])]
34-
#[ORM\Index(name: 'deleted_at', columns: ['deleted_at'])]
3534
class Consent
3635
{
3736
/**

0 commit comments

Comments
 (0)