<?php
declare(strict_types=1);
namespace CustomersBundleMigrations;
use App\Services\ObjectSerialize;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\Uid\UuidV6;
final class Version20240229143033 extends AbstractMigration
{
private ObjectSerialize $objectSerialize;
public function setObjectSerialize(ObjectSerialize $objectSerialize)
{
$this->objectSerialize = $objectSerialize;
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE customers_bundle__customer ADD reference VARCHAR(128) DEFAULT NULL');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => 'customers_bundle__reference_format',
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => 'CLI[[number]]']),
'created_at' => (new \DateTime())->format('Y-m-d H:i:s'),
'updated_at' => (new \DateTime())->format('Y-m-d H:i:s')
]);
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE customers_bundle__customer DROP reference');
}
}