32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* The admin UI has always labeled the deposit field "toman" but stored the raw
|
|
* entered number in deposit_amount_rials. The UI now converts toman → rial on
|
|
* save; this backfills existing rows so stored values become true rials.
|
|
*/
|
|
final class Version20260717093000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Convert existing appointment deposit amounts from toman to rials';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('UPDATE appointments SET deposit_amount_rials = deposit_amount_rials * 10 WHERE deposit_amount_rials IS NOT NULL AND deposit_amount_rials > 0');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('UPDATE appointments SET deposit_amount_rials = deposit_amount_rials / 10 WHERE deposit_amount_rials IS NOT NULL AND deposit_amount_rials > 0');
|
|
}
|
|
}
|