<?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 Version20231024125201 extends AbstractMigration
{
public function getDescription(): string
{
return 'Drop history, add field shopId for OrderSlip';
}
public function up(Schema $schema): void
{
$this->addSql('DROP TABLE history');
$this->addSql('ALTER TABLE order_slip ADD shop_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE order_slip ADD CONSTRAINT FK_B0C879EF4D16C4DD FOREIGN KEY (shop_id) REFERENCES shop (id)');
$this->addSql('CREATE INDEX IDX_B0C879EF4D16C4DD ON order_slip (shop_id)');
$this->addSql('ALTER TABLE order_slip RENAME INDEX idx_b0c879effcdaeaaa TO IDX_B0C879EF8D9F6D38');
}
public function down(Schema $schema): void
{
$this->addSql('CREATE TABLE history (id INT AUTO_INCREMENT NOT NULL, order_id INT NOT NULL, status VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, created_at DATETIME NOT NULL, old_status VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, INDEX IDX_27BA704B8D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE history ADD CONSTRAINT FK_27BA704B8D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('ALTER TABLE order_slip DROP FOREIGN KEY FK_B0C879EF4D16C4DD');
$this->addSql('DROP INDEX IDX_B0C879EF4D16C4DD ON order_slip');
$this->addSql('ALTER TABLE order_slip DROP shop_id');
$this->addSql('ALTER TABLE order_slip RENAME INDEX idx_b0c879ef8d9f6d38 TO IDX_B0C879EFFCDAEAAA');
}
}