- Changed franchise_rials to franchise_percent in tenant_insurances and tenant_service_coverage tables. - Reset old rial values to 0/NULL as they are not convertible to percentage. feat(command): add SeedInsuranceScenarioCommand for seeding insurance data - Implemented a command to seed supplementary insurance contracts, patients, and claims for a specified doctor. - Includes functionality for purging existing scenario data and generating new entries with predefined contracts and patient scenarios.
45 lines
1.9 KiB
PHP
45 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Franchise becomes a percentage instead of an amount.
|
|
*
|
|
* A supplementary insurance's franchise is quoted as a share ("فرانشیز ۱۰٪"), not
|
|
* as a fixed sum, and the old rial column forced every clinic to translate that
|
|
* share into a number that only held for one price. The stored rial values carry
|
|
* no percentage inside them and cannot be converted, so they are dropped to zero
|
|
* — contracts have to restate their franchise once, in percent.
|
|
*/
|
|
final class Version20260728180000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Franchise stored as a percentage (tenant_insurances, tenant_service_coverage); old rial values reset to 0/NULL because they are not convertible.';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE tenant_insurances CHANGE franchise_rials franchise_percent NUMERIC(5, 2) NOT NULL');
|
|
$this->addSql('UPDATE tenant_insurances SET franchise_percent = 0');
|
|
|
|
$this->addSql('ALTER TABLE tenant_service_coverage CHANGE franchise_rials franchise_percent NUMERIC(5, 2) DEFAULT NULL');
|
|
$this->addSql('UPDATE tenant_service_coverage SET franchise_percent = NULL');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// The rial amounts are gone for good; down() restores the shape, not the data.
|
|
$this->addSql('ALTER TABLE tenant_insurances CHANGE franchise_percent franchise_rials INT DEFAULT 0 NOT NULL');
|
|
$this->addSql('UPDATE tenant_insurances SET franchise_rials = 0');
|
|
|
|
$this->addSql('ALTER TABLE tenant_service_coverage CHANGE franchise_percent franchise_rials INT DEFAULT NULL');
|
|
$this->addSql('UPDATE tenant_service_coverage SET franchise_rials = NULL');
|
|
}
|
|
}
|