addSql('ALTER TABLE user ADD hotel_codes JSON NOT NULL COMMENT \'(DC2Type:json)\''); } public function postUp(Schema $schema): void { $this->connection->executeQuery('UPDATE user SET hotel_codes="[]" WHERE hotel_code IS NULL'); $rows = $this->connection->fetchAllAssociative('SELECT id, hotel_code FROM user WHERE hotel_code IS NOT NULL'); foreach ($rows as $row) { $this->connection->update('user', [ 'hotel_codes' => json_encode([$row['hotel_code']]), ], [ 'id' => $row['id'], ]); } } public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE user DROP hotel_codes'); } }