migrations/Version20250218084100.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 Version20250218084100 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Insert NEPTING TAP TO PAY payment_method_config';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql("
  15.             INSERT INTO payment_method_config (gateway_config_id, code, name, enabled, type, created_at, updated_at)
  16.             SELECT id, 'nepting-tap-to-pay', 'Nepting tap to pay', 1, 'online', NOW(), NOW()
  17.             FROM gateway_config
  18.             ORDER BY id DESC
  19.             LIMIT 1
  20.         ");
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         $this->addSql("SET foreign_key_checks = 0");
  25.         $this->addSql("DELETE FROM payment WHERE payment_method_id IN (SELECT id FROM payment_method WHERE payemnt_menthod_config_id IN (SELECT id FROM payment_method_config WHERE code = 'nepting-tap-to-pay'))");
  26.         $this->addSql("DELETE FROM payment_method WHERE payemnt_menthod_config_id IN (SELECT id FROM payment_method_config WHERE code = 'nepting-tap-to-pay')");
  27.         $this->addSql("DELETE FROM payment_method_config WHERE code = 'nepting-tap-to-pay'");
  28.         $this->addSql("SET foreign_key_checks = 1");
  29.     }
  30. }