<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use PaperKite\Common\Entity\Enum\DossierTypeCategoryEnumType;
use Symfony\Component\Uid\Uuid;
final class Version20230215181002 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fill in dossier type values';
}
public function up(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('dossier_type')
||
0 < $this->connection->executeQuery('SELECT COUNT(*) FROM dossier_type')->fetchOne(),
'The dossier_type table does not exists or is not empty!'
);
foreach (DossierTypeCategoryEnumType::getValues() as $value) {
$statement = $this->connection->prepare(
'INSERT INTO dossier_type (id, name, internal_id, category) VALUES (:id, :value, :value, :value);'
);
$statement->bindValue('id', Uuid::v4());
$statement->bindValue('value', $value);
$statement->executeQuery();
}
}
public function down(Schema $schema): void
{
}
}