mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-05 23:20:18 +02:00
Add unique index constraint for quiz_candidate with soft delete support
- Updated migration to include a unique index on `quiz_candidate` table that excludes soft-deleted records. - Adjusted `QuizCandidate` entity to reflect the new unique constraint with `deleted_at` condition.
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20260524121119 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add unique constraint for quiz_candidate with deleted_at filter';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('DROP INDEX uniq_ced2ffa291bd8781853cd175');
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_CED2FFA291BD8781853CD175 ON quiz_candidate (candidate_id, quiz_id) WHERE deleted_at IS NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('DROP INDEX UNIQ_CED2FFA291BD8781853CD175');
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX uniq_ced2ffa291bd8781853cd175 ON quiz_candidate (candidate_id, quiz_id)');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ use Tvdt\Repository\QuizCandidateRepository;
|
|||||||
|
|
||||||
#[Gedmo\SoftDeleteable]
|
#[Gedmo\SoftDeleteable]
|
||||||
#[ORM\Entity(repositoryClass: QuizCandidateRepository::class)]
|
#[ORM\Entity(repositoryClass: QuizCandidateRepository::class)]
|
||||||
#[ORM\UniqueConstraint(columns: ['candidate_id', 'quiz_id'])]
|
#[ORM\UniqueConstraint(columns: ['candidate_id', 'quiz_id'], options: ['where' => 'deleted_at IS NULL'])]
|
||||||
class QuizCandidate
|
class QuizCandidate
|
||||||
{
|
{
|
||||||
use SoftDeleteableEntity;
|
use SoftDeleteableEntity;
|
||||||
|
|||||||
Reference in New Issue
Block a user