Files
ephub/migrations/Version20260928161500.php
T

42 lines
1.3 KiB
PHP

<?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));
}
}
}