- Added `clinic_id` and `type` fields to `DoctorAddress` entity to differentiate between personal and clinic addresses. - Updated constructor to support creation of addresses for both doctors and clinics. - Modified repository methods to handle new address types and added methods for counting and finding addresses by clinic. - Implemented migration to update the database schema accordingly. - Removed deprecated endpoint for creating addresses from clinics and updated related controller methods. - Added new endpoints for managing clinic addresses, including CRUD operations. - Updated frontend components to handle new address types and display accordingly.
37 lines
1.6 KiB
PHP
37 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260612132848 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Add type, clinic_id to doctor_addresses; make doctor_id nullable to support clinic addresses';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql("ALTER TABLE doctor_addresses ADD COLUMN type VARCHAR(10) NOT NULL DEFAULT 'personal'");
|
|
$this->addSql("ALTER TABLE doctor_addresses ADD COLUMN clinic_id INT NULL");
|
|
$this->addSql("ALTER TABLE doctor_addresses ADD CONSTRAINT FK_doctor_addr_clinic FOREIGN KEY (clinic_id) REFERENCES clinics(id) ON DELETE CASCADE");
|
|
$this->addSql("CREATE INDEX idx_doctor_addr_clinic ON doctor_addresses (clinic_id)");
|
|
$this->addSql("ALTER TABLE doctor_addresses MODIFY COLUMN doctor_id INT NULL");
|
|
$this->addSql("ALTER TABLE doctor_addresses ADD CONSTRAINT chk_addr_owner CHECK (doctor_id IS NOT NULL OR clinic_id IS NOT NULL)");
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql("ALTER TABLE doctor_addresses DROP CONSTRAINT chk_addr_owner");
|
|
$this->addSql("ALTER TABLE doctor_addresses MODIFY COLUMN doctor_id INT NOT NULL");
|
|
$this->addSql("DROP INDEX idx_doctor_addr_clinic ON doctor_addresses");
|
|
$this->addSql("ALTER TABLE doctor_addresses DROP FOREIGN KEY FK_doctor_addr_clinic");
|
|
$this->addSql("ALTER TABLE doctor_addresses DROP COLUMN clinic_id");
|
|
$this->addSql("ALTER TABLE doctor_addresses DROP COLUMN type");
|
|
}
|
|
}
|