feat: add insurance and location management
- Introduced InsuranceType enum for insurance categorization. - Created InsuranceRepository for managing insurance entities. - Developed LocationController for handling provinces and cities, including CRUD operations. - Implemented City and Province entities with necessary fields and relationships. - Added CityRepository and ProvinceRepository for database interactions. - Established Specialty management with SpecialtyController, including CRUD operations. - Created Specialty and Tag entities with appropriate fields and relationships. - Implemented TagController for managing tags, including CRUD operations. - Added TagRepository for database interactions with tags.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Finish categories migration:
|
||||
* - Remove orphan rows from doctor_expertise (bad test data pointing to province IDs)
|
||||
* - Add FK constraint to doctor_expertise.service_id → doctor_services
|
||||
* - Migrate doctor_cities.category_id → city_id with FK to cities
|
||||
* - Drop categories table
|
||||
*/
|
||||
final class Version20260610140853 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Finish categories migration: fix doctor_expertise orphans, doctor_cities → city_id, drop categories';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// Remove rows in doctor_expertise whose service_id doesn't exist in doctor_services
|
||||
$this->addSql('DELETE FROM doctor_expertise WHERE service_id NOT IN (SELECT id FROM doctor_services)');
|
||||
|
||||
// Add FK constraint to doctor_expertise
|
||||
$this->addSql('ALTER TABLE doctor_expertise ADD CONSTRAINT FK_ED88BE60ED5CA9E6 FOREIGN KEY (service_id) REFERENCES doctor_services (id)');
|
||||
$this->addSql('CREATE INDEX IDX_ED88BE60ED5CA9E6 ON doctor_expertise (service_id)');
|
||||
|
||||
// doctor_cities: category_id → city_id with FK to cities
|
||||
$this->addSql('DELETE FROM doctor_cities WHERE category_id NOT IN (SELECT id FROM cities)');
|
||||
$this->addSql('ALTER TABLE doctor_cities DROP FOREIGN KEY `FK_7DC181E612469DE2`');
|
||||
$this->addSql('DROP INDEX IDX_7DC181E612469DE2 ON doctor_cities');
|
||||
$this->addSql('ALTER TABLE doctor_cities CHANGE category_id city_id INT NOT NULL, DROP PRIMARY KEY, ADD PRIMARY KEY (doctor_id, city_id)');
|
||||
$this->addSql('ALTER TABLE doctor_cities ADD CONSTRAINT FK_7DC181E68BAC62AF FOREIGN KEY (city_id) REFERENCES cities (id)');
|
||||
$this->addSql('CREATE INDEX IDX_7DC181E68BAC62AF ON doctor_cities (city_id)');
|
||||
|
||||
// Drop the now-unused categories table
|
||||
$this->addSql('DROP TABLE categories');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE doctor_expertise DROP FOREIGN KEY FK_ED88BE60ED5CA9E6');
|
||||
$this->addSql('DROP INDEX IDX_ED88BE60ED5CA9E6 ON doctor_expertise');
|
||||
|
||||
$this->addSql('ALTER TABLE doctor_cities DROP FOREIGN KEY FK_7DC181E68BAC62AF');
|
||||
$this->addSql('DROP INDEX IDX_7DC181E68BAC62AF ON doctor_cities');
|
||||
$this->addSql('ALTER TABLE doctor_cities CHANGE city_id category_id INT NOT NULL, DROP PRIMARY KEY, ADD PRIMARY KEY (doctor_id, category_id)');
|
||||
|
||||
$this->addSql("
|
||||
CREATE TABLE categories (
|
||||
id INT AUTO_INCREMENT NOT NULL,
|
||||
uuid VARCHAR(36) NOT NULL,
|
||||
bundle VARCHAR(32) NOT NULL,
|
||||
label VARCHAR(255) DEFAULT NULL,
|
||||
status SMALLINT NOT NULL,
|
||||
parent_id INT DEFAULT NULL,
|
||||
weight INT NOT NULL,
|
||||
logo_id INT DEFAULT NULL,
|
||||
title VARCHAR(255) DEFAULT NULL,
|
||||
representation_id INT DEFAULT NULL,
|
||||
contact_phone VARCHAR(255) DEFAULT NULL,
|
||||
email VARCHAR(255) DEFAULT NULL,
|
||||
description LONGTEXT DEFAULT NULL,
|
||||
slogan VARCHAR(255) DEFAULT NULL,
|
||||
domain VARCHAR(255) DEFAULT NULL,
|
||||
keywords VARCHAR(255) DEFAULT NULL,
|
||||
footer_description LONGTEXT DEFAULT NULL,
|
||||
footer_disclaimer LONGTEXT DEFAULT NULL,
|
||||
social_media LONGTEXT DEFAULT NULL,
|
||||
logo_url VARCHAR(500) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) DEFAULT CHARACTER SET utf8mb4
|
||||
");
|
||||
|
||||
$this->addSql('ALTER TABLE doctor_cities ADD CONSTRAINT `FK_7DC181E612469DE2` FOREIGN KEY (category_id) REFERENCES categories (id)');
|
||||
$this->addSql('CREATE INDEX IDX_7DC181E612469DE2 ON doctor_cities (category_id)');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user