migrations/Version20241028074517.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 Version20241028074517 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add the nepting ePay payment method';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql("INSERT INTO `gateway_config` (`id`, `config`) VALUES (NULL, '[{\"name\": \"merchantId\", \"value\": \"string\", \"length\": 65, \"private\": true, \"is_global\": false}, {\"name\": \"merchantLabel\", \"value\": \"string\", \"length\": 120, \"private\": true, \"is_global\": false}, {\"name\": \"key\", \"value\": \"string\", \"length\": 100, \"private\": true, \"is_global\": false}, {\"name\": \"errorUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}, {\"name\": \"successUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}, {\"name\": \"refusedUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}, {\"name\": \"cancelUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}]')");
  15.         $this->addSql('INSERT INTO `payment_method_config` (`id`, `gateway_config_id`, `code`, `name`, `enabled`, `type`, `created_at`, `updated_at`) (SELECT NULL, (SELECT MAX(id) FROM gateway_config), "nepting-epay", "Nepting ePay", "1", "online", NOW(), NOW())');
  16.     }
  17.     public function down(Schema $schema): void
  18.     {
  19.         $gatewayConfigId $this->connection->fetchOne('SELECT gateway_config_id FROM payment_method_config pmc WHERE pmc.code = "nepting-epay"');
  20.         $this->addSql('DELETE FROM `payment_method_config` WHERE code = "nepting-epay"');
  21.         $this->addSql("DELETE FROM `gateway_config` WHERE id = {$gatewayConfigId}");
  22.     }
  23. }