<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230705150340 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('INSERT INTO payment_method (id, name, name_alt, used_by_default, created_at, updated_at) VALUES
(uuid(), "40% mediante transferencia bancaria la confirmación de pedido y 60% antes de la carga", "40% at order confirmation by swift transfer and 60% before loading", 1, NOW(), NOW()),
(uuid(), "100% transferencia a la vista", "100% swift transfer at sight", 0, NOW(), NOW())');
$this->addSql('ALTER TABLE offer ADD payment_method_id VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE offer ADD CONSTRAINT FK_29D6873E5AA1164F FOREIGN KEY (payment_method_id) REFERENCES payment_method (id)');
$this->addSql('CREATE INDEX IDX_29D6873E5AA1164F ON offer (payment_method_id)');
$this->addSql('UPDATE offer set payment_method_id = (SELECT id FROM payment_method WHERE name = "40% mediante transferencia bancaria la confirmación de pedido y 60% antes de la carga") where payment_method like "%40%"');
$this->addSql('UPDATE offer set payment_method_id = (SELECT id FROM payment_method WHERE name = "100% transferencia a la vista") where payment_method like "%100%"');
$this->addSql('ALTER TABLE offer DROP payment_method');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE offer DROP FOREIGN KEY FK_29D6873E5AA1164F');
$this->addSql('DROP INDEX IDX_29D6873E5AA1164F ON offer');
$this->addSql('ALTER TABLE offer DROP payment_method_id ');
$this->addSql('DELETE FROM payment_method WHERE name = "40% mediante transferencia bancaria la confirmación de pedido y 60% antes de la carga"');
$this->addSql('DELETE FROM payment_method WHERE name = "100% transferencia a la vista"');
}
}