<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250218084100 extends AbstractMigration
{
public function getDescription(): string
{
return 'Insert NEPTING TAP TO PAY payment_method_config';
}
public function up(Schema $schema): void
{
$this->addSql("
INSERT INTO payment_method_config (gateway_config_id, code, name, enabled, type, created_at, updated_at)
SELECT id, 'nepting-tap-to-pay', 'Nepting tap to pay', 1, 'online', NOW(), NOW()
FROM gateway_config
ORDER BY id DESC
LIMIT 1
");
}
public function down(Schema $schema): void
{
$this->addSql("SET foreign_key_checks = 0");
$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'))");
$this->addSql("DELETE FROM payment_method WHERE payemnt_menthod_config_id IN (SELECT id FROM payment_method_config WHERE code = 'nepting-tap-to-pay')");
$this->addSql("DELETE FROM payment_method_config WHERE code = 'nepting-tap-to-pay'");
$this->addSql("SET foreign_key_checks = 1");
}
}