Files
clinicpro/migrations/Version20260625150304.php
T
hamed c2c6ae4d02 feat(migrations): add national_code_verified flag to users and normalize bank_account representation
- Added a new column `national_code_verified` to the `users` table.
- Normalized the `bank_account` field in the `representations` table from a single object to an array of IBANs with a default `verified` status of false.

feat(ApiIrService): implement identity verification client for api.ir

- Created `ApiIrService` to handle identity verification via api.ir.
- Implemented methods for matching national code with mobile and IBAN with national code and birth date.
- Added error handling and logging for external API requests.
2026-06-25 19:38:47 +03:30

54 lines
1.9 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 Version20260625150304 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add users.national_code_verified flag; normalize representations.bank_account (single object → array of IBANs).';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE users ADD national_code_verified TINYINT(1) NOT NULL DEFAULT 0');
// نرمال‌سازی داده‌ی قدیمی: bank_account تکی → آرایه‌ی تک‌عضوی با verified=false.
// فقط رکوردهایی که bank_account دارند و هنوز آرایه نیستند (با "{" شروع می‌شوند).
$rows = $this->connection->fetchAllAssociative(
"SELECT id, bank_account FROM representations WHERE bank_account IS NOT NULL AND bank_account LIKE '{%'"
);
foreach ($rows as $row) {
$old = json_decode((string) $row['bank_account'], true);
if (!is_array($old)) {
continue;
}
$normalized = [[
'id' => bin2hex(random_bytes(16)),
'iban' => $old['iban'] ?? '',
'bank_name' => $old['bank_name'] ?? null,
'owner_name' => $old['owner_name'] ?? null,
'verified' => false,
'created_at' => time(),
]];
$this->connection->executeStatement(
'UPDATE representations SET bank_account = :v WHERE id = :id',
['v' => json_encode($normalized, JSON_UNESCAPED_UNICODE), 'id' => $row['id']]
);
}
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE users DROP national_code_verified');
}
}