migrations/Version20250709120000.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 Version20250709120000 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add status column to privatisation entity and back-fill existing rows to confirmed';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         // 1. Add column with default "pending_validation" so the NOT NULL constraint passes for existing rows
  15.         $this->addSql("ALTER TABLE privatisation ADD status VARCHAR(50) NOT NULL DEFAULT 'pending_validation'");
  16.         // 2. Back-fill existing rows created before this migration to 'confirmed'
  17.         $this->addSql("UPDATE privatisation SET status = 'confirmed'");
  18.     }
  19.     public function down(Schema $schema): void
  20.     {
  21.         $this->addSql('ALTER TABLE privatisation DROP status');
  22.     }