<?php
declare(strict_types=1);
namespace SalesBundleMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230622124455 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE sales_bundle__quotation ADD lost TINYINT(1) DEFAULT 0 NOT NULL, ADD closed TINYINT(1) DEFAULT 0 NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE sales_bundle__quotation DROP lost, DROP closed');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$query = "UPDATE `sales_bundle__quotation` q
SET q.closed = 1, q.archived = 0
WHERE q.archived = 1 AND q.validated_at IS NOT NULL
";
try {
$conn = $this->connection->prepare($query);
$conn->executeQuery();
} catch (\Exception $e) {
}
}
}