migrations/Version20250218084035.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20250218084035 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Insert NEPTING TAP TO PAY gateway_config';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $configJson json_encode([
  15.             [
  16.                 'name' => 'merchantId',
  17.                 'value' => 'string',
  18.                 'length' => 65,
  19.                 'private' => false,
  20.                 'is_global' => false,
  21.             ],
  22.             [
  23.                 'name' => 'posEditor',
  24.                 'value' => 'Nepting',
  25.                 'length' => 65,
  26.                 'private' => true,
  27.                 'is_global' => true,
  28.             ],
  29.             [
  30.                 'name' => 'posSolution',
  31.                 'value' => 'Nepting TapToPay App',
  32.                 'length' => 65,
  33.                 'private' => true,
  34.                 'is_global' => true,
  35.             ],
  36.             [
  37.                 'name' => 'posVersion',
  38.                 'value' => '1.0.0',
  39.                 'length' => 65,
  40.                 'private' => true,
  41.                 'is_global' => true,
  42.             ],
  43.             [
  44.                 'name' => 'posSignKeyAlias',
  45.                 'value' => 'KEY-QUALIF',
  46.                 'length' => 65,
  47.                 'private' => true,
  48.                 'is_global' => true,
  49.             ]
  50.         ]);
  51.         $this->addSql("INSERT INTO gateway_config (config) VALUES ('$configJson')");
  52.     }
  53.     public function down(Schema $schema): void
  54.     {
  55.         $this->addSql("
  56.             DELETE FROM gateway_config 
  57.             WHERE JSON_SEARCH(config, 'one', 'merchantId', NULL, '$[*].name') IS NOT NULL
  58.                AND JSON_SEARCH(config, 'one', 'posEditor', NULL, '$[*].name') IS NOT NULL
  59.                AND JSON_SEARCH(config, 'one', 'posSolution', NULL, '$[*].name') IS NOT NULL
  60.                AND JSON_SEARCH(config, 'one', 'posVersion', NULL, '$[*].name') IS NOT NULL
  61.                AND JSON_SEARCH(config, 'one', 'posSignKeyAlias', NULL, '$[*].name') IS NOT NULL
  62.         ");
  63.     }
  64. }