<?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 Version20211208145724 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE `payment_method` (id INT AUTO_INCREMENT NOT NULL, order_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, amount NUMERIC(10, 0) NOT NULL, INDEX IDX_7B61A1F68D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE `payment_method` ADD CONSTRAINT FK_7B61A1F68D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)');
$this->addSql('INSERT INTO payment_method (type, amount, order_id) SELECT payment_method, net_amount, id FROM `order`;');
$this->addSql('ALTER TABLE `order` DROP COLUMN payment_method;');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE `payment_method`');
}
}