vendor/bluue/customers-bundle/migrations/Version20240229143033.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace CustomersBundleMigrations;
  4. use App\Services\ObjectSerialize;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. use Symfony\Component\Uid\UuidV6;
  8. final class Version20240229143033 extends AbstractMigration
  9. {
  10.     private ObjectSerialize $objectSerialize;
  11.     public function setObjectSerialize(ObjectSerialize $objectSerialize)
  12.     {
  13.         $this->objectSerialize $objectSerialize;
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('ALTER TABLE customers_bundle__customer ADD reference VARCHAR(128) DEFAULT NULL');
  18.     }
  19.     public function postUp(Schema $schema): void
  20.     {
  21.         parent::postUp($schema);
  22.         $this->connection->insert('configuration', [
  23.             'id' => (new UuidV6())->toBinary(),
  24.             'name' => 'customers_bundle__reference_format',
  25.             'context_id' => null,
  26.             'value' => $this->objectSerialize->add((object) ['value' => 'CLI[[number]]']),
  27.             'created_at' => (new \DateTime())->format('Y-m-d H:i:s'),
  28.             'updated_at' => (new \DateTime())->format('Y-m-d H:i:s')
  29.         ]);
  30.     }
  31.     public function down(Schema $schema): void
  32.     {
  33.         $this->addSql('ALTER TABLE customers_bundle__customer DROP reference');
  34.     }
  35. }