mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-06 15:40:14 +02:00
cab2d25000
- 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.
53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tvdt\Entity;
|
|
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Gedmo\Mapping\Annotation as Gedmo;
|
|
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
|
|
use Symfony\Bridge\Doctrine\Types\UuidType;
|
|
use Symfony\Component\Uid\Uuid;
|
|
use Tvdt\Repository\QuizCandidateRepository;
|
|
|
|
#[Gedmo\SoftDeleteable]
|
|
#[ORM\Entity(repositoryClass: QuizCandidateRepository::class)]
|
|
#[ORM\UniqueConstraint(columns: ['candidate_id', 'quiz_id'], options: ['where' => 'deleted_at IS NULL'])]
|
|
class QuizCandidate
|
|
{
|
|
use SoftDeleteableEntity;
|
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
|
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
#[ORM\Id]
|
|
public private(set) Uuid $id;
|
|
|
|
#[ORM\Column]
|
|
public float $corrections = 0;
|
|
|
|
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
|
public int $penaltySeconds = 0;
|
|
|
|
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => true])]
|
|
public bool $active = true;
|
|
|
|
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: true)]
|
|
public ?\DateTimeImmutable $started = null;
|
|
|
|
#[Gedmo\Timestampable(on: 'create')]
|
|
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
|
|
public private(set) \DateTimeImmutable $created;
|
|
|
|
public function __construct(
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
#[ORM\ManyToOne(inversedBy: 'candidateData')]
|
|
public Quiz $quiz,
|
|
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
#[ORM\ManyToOne(inversedBy: 'quizData')]
|
|
public Candidate $candidate,
|
|
) {}
|
|
}
|