migrations/Version20250326111047.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20250326111047 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Update deleted devices names with (deleted at TIMESTAMP)';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql("
  15.             UPDATE device 
  16.             SET name = CONCAT(name, ' (deleted at ', UNIX_TIMESTAMP(deleted_at), ')') 
  17.             WHERE deleted_at IS NOT NULL
  18.         ");
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         $this->addSql("
  23.             UPDATE device 
  24.             SET name = SUBSTRING_INDEX(name, ' (deleted at ', 1) 
  25.             WHERE deleted_at IS NOT NULL
  26.         ");
  27.     }
  28. }