Files
clinicpro/migrations/Version20260628133044.php
T
hamed 36b87e9817 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.
2026-06-28 17:04:23 +03:30

36 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260628133044 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add ON DELETE CASCADE to doctor_insurances.insurance_id and doctor_secretaries.secretary_id (required FKs that had no referential action). The RESTRICT FKs added in the same change (Doctor/Clinic.user_id, invited_by_id, subscription plan/period) need no DDL — RESTRICT is the MySQL default.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE doctor_insurances DROP FOREIGN KEY `FK_5317E58ED1E63CD1`');
$this->addSql('ALTER TABLE doctor_insurances ADD CONSTRAINT FK_5317E58ED1E63CD1 FOREIGN KEY (insurance_id) REFERENCES insurances (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE doctor_secretaries DROP FOREIGN KEY `FK_8DF480E9A2A63DB2`');
$this->addSql('ALTER TABLE doctor_secretaries ADD CONSTRAINT FK_8DF480E9A2A63DB2 FOREIGN KEY (secretary_id) REFERENCES users (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE doctor_insurances DROP FOREIGN KEY FK_5317E58ED1E63CD1');
$this->addSql('ALTER TABLE doctor_insurances ADD CONSTRAINT `FK_5317E58ED1E63CD1` FOREIGN KEY (insurance_id) REFERENCES insurances (id)');
$this->addSql('ALTER TABLE doctor_secretaries DROP FOREIGN KEY FK_8DF480E9A2A63DB2');
$this->addSql('ALTER TABLE doctor_secretaries ADD CONSTRAINT `FK_8DF480E9A2A63DB2` FOREIGN KEY (secretary_id) REFERENCES users (id)');
}
}