<?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 Version20231121123506 extends AbstractMigration
{
private $idToInsert = 20;
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// Check if ID already exists or not
$idExists = $this->isIdExists($this->idToInsert);
if (!$idExists) {
$this->addSql("INSERT INTO `dtb_mail_template` (`id`, `creator_id`, `name`, `file_name`, `mail_subject`, `create_date`, `update_date`, `discriminator_type`) VALUES ($this->idToInsert, NULL, '注文受付メール(宅配レンタル)', 'Mail/order.twig', 'ご注文ありがとうございます(自動返信メール)', '2023-11-21 12:38:34.000000', '2023-11-21 12:38:34.000000', 'mailtemplate')");
}
}
public function down(Schema $schema): void
{
$this->addSql("DELETE FROM `dtb_mail_template` where id = $this->idToInsert");
}
private function isIdExists(int $id): bool
{
try {
$result = $this->connection->fetchOne("SELECT id FROM dtb_mail_template WHERE id = :id", ['id' => $id]);
return $result !== false;
} catch (\Exception $e) {
return false;
}
}
}