<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250218084035 extends AbstractMigration
{
public function getDescription(): string
{
return 'Insert NEPTING TAP TO PAY gateway_config';
}
public function up(Schema $schema): void
{
$configJson = json_encode([
[
'name' => 'merchantId',
'value' => 'string',
'length' => 65,
'private' => false,
'is_global' => false,
],
[
'name' => 'posEditor',
'value' => 'Nepting',
'length' => 65,
'private' => true,
'is_global' => true,
],
[
'name' => 'posSolution',
'value' => 'Nepting TapToPay App',
'length' => 65,
'private' => true,
'is_global' => true,
],
[
'name' => 'posVersion',
'value' => '1.0.0',
'length' => 65,
'private' => true,
'is_global' => true,
],
[
'name' => 'posSignKeyAlias',
'value' => 'KEY-QUALIF',
'length' => 65,
'private' => true,
'is_global' => true,
]
]);
$this->addSql("INSERT INTO gateway_config (config) VALUES ('$configJson')");
}
public function down(Schema $schema): void
{
$this->addSql("
DELETE FROM gateway_config
WHERE JSON_SEARCH(config, 'one', 'merchantId', NULL, '$[*].name') IS NOT NULL
AND JSON_SEARCH(config, 'one', 'posEditor', NULL, '$[*].name') IS NOT NULL
AND JSON_SEARCH(config, 'one', 'posSolution', NULL, '$[*].name') IS NOT NULL
AND JSON_SEARCH(config, 'one', 'posVersion', NULL, '$[*].name') IS NOT NULL
AND JSON_SEARCH(config, 'one', 'posSignKeyAlias', NULL, '$[*].name') IS NOT NULL
");
}
}