migrations/Version20261015130000.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 Version20261015130000 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Replace menu.texto with structured dishes and a coffee policy; texto data is dropped without backfill and down() cannot restore it';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql("ALTER TABLE menu DROP texto, ADD coffee VARCHAR(32) DEFAULT 'instead_of_dessert' NOT NULL");
  15.         $this->addSql('CREATE TABLE dish (id INT AUTO_INCREMENT NOT NULL, menu_id INT NOT NULL, course VARCHAR(16) NOT NULL, name VARCHAR(150) NOT NULL, search_name VARCHAR(150) NOT NULL, supplement NUMERIC(6, 2) DEFAULT NULL, position INT NOT NULL, INDEX IDX_957D8CB8CCD7E912 (menu_id), INDEX idx_dish_search_name (search_name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  16.         $this->addSql('ALTER TABLE dish ADD CONSTRAINT FK_957D8CB8CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id) ON DELETE CASCADE');
  17.     }
  18.     public function down(Schema $schema): void
  19.     {
  20.         $this->addSql('DROP TABLE dish');
  21.         $this->addSql('ALTER TABLE menu DROP coffee, ADD texto LONGTEXT DEFAULT NULL');
  22.     }
  23. }