Migrate legacy attachment discriminator class values to modern format, so that we can make the discriminator map unique and fix a deprecation with doctrine

This commit is contained in:
Jan Böhmer 2025-02-22 17:58:20 +01:00
parent f146d88aa5
commit 019e67a676
2 changed files with 33 additions and 2 deletions

View file

@ -0,0 +1,31 @@
<?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 Version20250222165240 extends AbstractMigration
{
public function getDescription(): string
{
return 'Migrate the old attachment class discriminator values from legacy Part-DB to the modern format, so that there is just one unified value';
}
public function up(Schema $schema): void
{
//Change the old discriminator values to the new ones
$this->addSql('UPDATE attachments SET class_name = "Part" WHERE class_name = "PartDB\Part"');
$this->addSql('UPDATE attachments SET class_name = "Device" WHERE class_name = "PartDB\Device"');
}
public function down(Schema $schema): void
{
//No down required, as the new format can also be read by older Part-DB version
}
}