refactor: rename the monitor resource type to hardware

This commit is contained in:
fromme committed 2026-09-28 16:41:00 +02:00
1 parent d287cb2600
commit af73dcdc2d
2 files changed
+47 -6

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* The kind outgrew "a monitor": it now covers any piece of hardware that can be lent out, and
* the enum case was renamed from MONITOR to HARDWARE. This brings the stored backing value along,
* so nothing keeps the old word alive -- there are no bookmarked /board/monitor URLs to break.
*
* Every table with a `type` column mapped to ResourceType is updated, not just `resource`:
* a group and a settings row are addressed by the same backing value, and a row left behind
* would simply stop matching its kind.
*/
final class Version20260928161500 extends AbstractMigration
{
private const TABLES = ['resource', 'resource_group', 'resource_type_settings'];
public function getDescription(): string
{
return 'Renames the monitor resource type to hardware';
}
public function up(Schema $schema): void
{
foreach (self::TABLES as $table) {
$this->addSql(\sprintf("UPDATE %s SET type = 'hardware' WHERE type = 'monitor'", $table));
}
}
public function down(Schema $schema): void
{
foreach (self::TABLES as $table) {
$this->addSql(\sprintf("UPDATE %s SET type = 'monitor' WHERE type = 'hardware'", $table));
}
}
}