<?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 Version20260116134623 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update order status from 99 to 5 and delete order status with id 5';
}
public function up(Schema $schema): void
{
// Update all orders with status 99 to status 5
$this->addSql("
UPDATE dtb_order
SET order_status_id = 5
WHERE order_status_id = 99
");
// Delete order status with id 99
$this->addSql("
DELETE FROM mtb_order_status
WHERE id = 99
");
}
public function down(Schema $schema): void
{
// Recreate order status with id 99 (発送済み)
$this->addSql("
INSERT INTO mtb_order_status (
id,
name,
display_order_count,
sort_no,
discriminator_type
)
SELECT
99,
'発送済み',
0,
1,
'orderstatus'
WHERE NOT EXISTS (
SELECT 1 FROM mtb_order_status WHERE id = 99
)
");
// Revert orders from status 5 back to status 99
$this->addSql("
UPDATE dtb_order
SET order_status_id = 99
WHERE order_status_id = 5
");
}
}