migrations/Version20230705150340.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. /**
  7. * Auto-generated Migration: Please modify to your needs!
  8. */
  9. final class Version20230705150340 extends AbstractMigration
  10. {
  11. public function getDescription(): string
  12. {
  13. return '';
  14. }
  15. public function up(Schema $schema): void
  16. {
  17. $this->addSql('INSERT INTO payment_method (id, name, name_alt, used_by_default, created_at, updated_at) VALUES
  18. (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()),
  19. (uuid(), "100% transferencia a la vista", "100% swift transfer at sight", 0, NOW(), NOW())');
  20. $this->addSql('ALTER TABLE offer ADD payment_method_id VARCHAR(255) DEFAULT NULL');
  21. $this->addSql('ALTER TABLE offer ADD CONSTRAINT FK_29D6873E5AA1164F FOREIGN KEY (payment_method_id) REFERENCES payment_method (id)');
  22. $this->addSql('CREATE INDEX IDX_29D6873E5AA1164F ON offer (payment_method_id)');
  23. $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%"');
  24. $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%"');
  25. $this->addSql('ALTER TABLE offer DROP payment_method');
  26. }
  27. public function down(Schema $schema): void
  28. {
  29. $this->addSql('ALTER TABLE offer DROP FOREIGN KEY FK_29D6873E5AA1164F');
  30. $this->addSql('DROP INDEX IDX_29D6873E5AA1164F ON offer');
  31. $this->addSql('ALTER TABLE offer DROP payment_method_id ');
  32. $this->addSql('DELETE FROM payment_method WHERE name = "40% mediante transferencia bancaria la confirmación de pedido y 60% antes de la carga"');
  33. $this->addSql('DELETE FROM payment_method WHERE name = "100% transferencia a la vista"');
  34. }
  35. }