Files
clinicpro/migrations/Version20260615074107.php
hamed 4bf381ac94 feat(secretary): implement scope separation for secretaries in clinics and personal practices
- Added `owner_type` and `clinic_id` fields to `DoctorSecretary` entity to distinguish between clinic and personal practice relationships.
- Updated repository methods to be scope-aware, allowing for specific queries based on the context of the secretary's relationship (clinic or doctor).
- Modified `SecretaryController` to handle secretary creation with appropriate scope based on the current user's role.
- Enhanced `AuthController` to build contexts that reflect the scope of the secretary's access.
- Updated `DashboardController` and `PatientController` to respect the new scope logic when retrieving data.
- Created migration to update the database schema accordingly, dropping the old unique constraint and adding the new fields and constraints.
2026-06-15 11:19:37 +03:30

40 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 Version20260615074107 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX idx_doctor_secretaries_pair ON doctor_secretaries');
$this->addSql('ALTER TABLE doctor_secretaries ADD owner_type VARCHAR(10) DEFAULT \'doctor\' NOT NULL, ADD clinic_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE doctor_secretaries ADD CONSTRAINT FK_8DF480E9CC22AD4 FOREIGN KEY (clinic_id) REFERENCES clinics (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_8DF480E9CC22AD4 ON doctor_secretaries (clinic_id)');
$this->addSql('CREATE UNIQUE INDEX idx_doctor_secretary_scope ON doctor_secretaries (doctor_id, secretary_id, owner_type)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE doctor_secretaries DROP FOREIGN KEY FK_8DF480E9CC22AD4');
$this->addSql('DROP INDEX IDX_8DF480E9CC22AD4 ON doctor_secretaries');
$this->addSql('DROP INDEX idx_doctor_secretary_scope ON doctor_secretaries');
$this->addSql('ALTER TABLE doctor_secretaries DROP owner_type, DROP clinic_id');
$this->addSql('CREATE UNIQUE INDEX idx_doctor_secretaries_pair ON doctor_secretaries (doctor_id, secretary_id)');
}
}