fix(db): declare onDelete on required FKs that had none
Eight required (nullable:false) FKs had no referential action. Set per the codebase's existing pattern: CASCADE for owned relations (doctor_insurances, doctor_secretaries), RESTRICT for owner/reference FKs (Doctor/Clinic.user_id, invited_by_id, subscription plan/period). Only the two CASCADE FKs need DDL — RESTRICT is the MySQL default.
This commit is contained in:
@@ -29,7 +29,7 @@ class Clinic
|
||||
private string $uuid;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)]
|
||||
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false, onDelete: 'RESTRICT')]
|
||||
private User $user;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255, nullable: true)]
|
||||
|
||||
@@ -34,7 +34,7 @@ class ClinicDoctorInvitation
|
||||
private Clinic $clinic;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(name: 'invited_by_id', referencedColumnName: 'id', nullable: false)]
|
||||
#[ORM\JoinColumn(name: 'invited_by_id', referencedColumnName: 'id', nullable: false, onDelete: 'RESTRICT')]
|
||||
private User $invitedBy;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Doctor::class)]
|
||||
|
||||
@@ -32,7 +32,7 @@ class Doctor
|
||||
private string $uuid;
|
||||
|
||||
#[ORM\OneToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)]
|
||||
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false, onDelete: 'RESTRICT')]
|
||||
private User $user;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
|
||||
@@ -22,7 +22,7 @@ class DoctorInsurance
|
||||
private Doctor $doctor;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Insurance::class)]
|
||||
#[ORM\JoinColumn(name: 'insurance_id', referencedColumnName: 'id', nullable: false)]
|
||||
#[ORM\JoinColumn(name: 'insurance_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
|
||||
private Insurance $insurance;
|
||||
|
||||
#[ORM\Column(type: 'integer', nullable: true)]
|
||||
|
||||
@@ -40,7 +40,7 @@ class DoctorSecretary
|
||||
private Doctor $doctor;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(name: 'secretary_id', referencedColumnName: 'id', nullable: false)]
|
||||
#[ORM\JoinColumn(name: 'secretary_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
|
||||
private User $secretary;
|
||||
|
||||
#[ORM\Column(name: 'owner_type', type: 'string', length: 10, options: ['default' => 'doctor'])]
|
||||
|
||||
@@ -27,11 +27,11 @@ class ClinicSubscription
|
||||
private int $entityId;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: SubscriptionPlan::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'RESTRICT')]
|
||||
private SubscriptionPlan $plan;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: SubscriptionPeriod::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'RESTRICT')]
|
||||
private SubscriptionPeriod $period;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Payment::class)]
|
||||
|
||||
@@ -19,7 +19,7 @@ class SubscriptionPeriod
|
||||
private string $uuid;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: SubscriptionPlan::class, inversedBy: 'periods')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'RESTRICT')]
|
||||
private SubscriptionPlan $plan;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 50)]
|
||||
|
||||
Reference in New Issue
Block a user