Files
clinicpro/migrations/Version20260705081716.php
T

51 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* اصلاح token_map تمپلت‌های پیامک تا هرکدام حتماً %token داشته باشند (الزام VerifyLookup کاوه‌نگار).
* payment/doctor_appointment/welcome قبلاً token نداشتند.
*/
final class Version20260705081716 extends AbstractMigration
{
private const FIX = [
'payment' => ['{"date":"token","time":"token2","doctor":"token10"}', 'نوبت شما با {doctor} در تاریخ {date} ساعت {time} ثبت و تأیید شد.'],
'doctor_appointment' => ['{"date":"token","time":"token2","patient":"token10"}', null],
'welcome' => ['{"name":"token","site":"token10"}', null],
];
public function getDescription(): string
{
return 'token_map پیامک‌ها: تضمین وجود %token در payment/doctor_appointment/welcome';
}
public function up(Schema $schema): void
{
foreach (self::FIX as $tag => [$map, $body]) {
if ($body !== null) {
$this->addSql(
'UPDATE sms_message_templates SET token_map = :map, body = :body WHERE tag = :tag',
['map' => $map, 'body' => $body, 'tag' => $tag]
);
} else {
$this->addSql(
'UPDATE sms_message_templates SET token_map = :map WHERE tag = :tag',
['map' => $map, 'tag' => $tag]
);
}
}
}
public function down(Schema $schema): void
{
$this->addSql("UPDATE sms_message_templates SET token_map = '{\"doctor\":\"token10\",\"date\":\"token20\"}', body = 'نوبت شما با {doctor} در تاریخ {date} ثبت و تأیید شد.' WHERE tag = 'payment'");
$this->addSql("UPDATE sms_message_templates SET token_map = '{\"patient\":\"token10\",\"date\":\"token2\",\"time\":\"token3\"}' WHERE tag = 'doctor_appointment'");
$this->addSql("UPDATE sms_message_templates SET token_map = '{\"name\":\"token10\",\"site\":\"token20\"}' WHERE tag = 'welcome'");
}
}