<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250326111047 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update deleted devices names with (deleted at TIMESTAMP)';
}
public function up(Schema $schema): void
{
$this->addSql("
UPDATE device
SET name = CONCAT(name, ' (deleted at ', UNIX_TIMESTAMP(deleted_at), ')')
WHERE deleted_at IS NOT NULL
");
}
public function down(Schema $schema): void
{
$this->addSql("
UPDATE device
SET name = SUBSTRING_INDEX(name, ' (deleted at ', 1)
WHERE deleted_at IS NOT NULL
");
}
}