migrations/Version20261019120000.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 Version20261019120000 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add menu.tags (diet tags the restaurant declares for the whole menu, as a JSON list); existing menus get no tags. DDL auto-commits: if this fails midway the menu.tags column may already exist (drop it and re-run)';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         // Same three steps as dish.tags: a JSON column cannot have a literal default and an expression default is not
  15.         // portable to MariaDB/MySQL 5.7.
  16.         $this->addSql('ALTER TABLE menu ADD tags JSON DEFAULT NULL');
  17.         $this->addSql('UPDATE menu SET tags = JSON_ARRAY()');
  18.         $this->addSql('ALTER TABLE menu CHANGE tags tags JSON NOT NULL');
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         $this->addSql('ALTER TABLE menu DROP tags');
  23.     }
  24. }