addSql('ALTER TABLE blogs ADD meta_title VARCHAR(255) DEFAULT NULL, ADD meta_description VARCHAR(500) DEFAULT NULL, ADD primary_keyword VARCHAR(255) DEFAULT NULL, ADD reading_time INT DEFAULT NULL, ADD canonical_url VARCHAR(500) DEFAULT NULL, ADD og_image VARCHAR(500) DEFAULT NULL, ADD scheduled_at INT DEFAULT NULL, ADD representation_id INT DEFAULT NULL'); // JSON NOT NULL columns can't be added directly to a table with rows (the // empty backfill fails json_valid). Add nullable, backfill '[]', then enforce. $this->addSql('ALTER TABLE blogs ADD secondary_keywords JSON DEFAULT NULL, ADD faq JSON DEFAULT NULL, ADD internal_links JSON DEFAULT NULL, ADD external_links JSON DEFAULT NULL'); $this->addSql("UPDATE blogs SET secondary_keywords = '[]', faq = '[]', internal_links = '[]', external_links = '[]'"); $this->addSql('ALTER TABLE blogs MODIFY secondary_keywords JSON NOT NULL, MODIFY faq JSON NOT NULL, MODIFY internal_links JSON NOT NULL, MODIFY external_links JSON NOT NULL'); $this->addSql('ALTER TABLE blogs ADD CONSTRAINT FK_F41BCA7046CE82F4 FOREIGN KEY (representation_id) REFERENCES representations (id) ON DELETE SET NULL'); $this->addSql('CREATE INDEX IDX_F41BCA7046CE82F4 ON blogs (representation_id)'); $this->addSql('CREATE INDEX idx_blogs_scheduled_at ON blogs (scheduled_at)'); $this->addSql('CREATE INDEX idx_blogs_representation ON blogs (representation_id, created_at)'); } public function down(Schema $schema): void { $this->addSql('ALTER TABLE blogs DROP FOREIGN KEY FK_F41BCA7046CE82F4'); $this->addSql('DROP INDEX IDX_F41BCA7046CE82F4 ON blogs'); $this->addSql('DROP INDEX idx_blogs_scheduled_at ON blogs'); $this->addSql('DROP INDEX idx_blogs_representation ON blogs'); $this->addSql('ALTER TABLE blogs DROP meta_title, DROP meta_description, DROP primary_keyword, DROP secondary_keywords, DROP faq, DROP internal_links, DROP external_links, DROP reading_time, DROP canonical_url, DROP og_image, DROP scheduled_at, DROP representation_id'); } }