addSql('ALTER TABLE accommodation_booking ADD type VARCHAR(20) DEFAULT NULL'); // An old 'booking' row with an accepted_at came from an accepted offer, so it is an // Anfrage; without one it was placed directly. Rows in 'draft'/'discarded' carry no // trace of their kind any more — they are mapped to 'inquiry', which is where the // office path produces them. $this->addSql("UPDATE accommodation_booking SET type = CASE WHEN status = 'booking' AND accepted_at IS NULL THEN 'booking' ELSE 'inquiry' END"); $this->addSql("UPDATE accommodation_booking SET status = CASE WHEN status = 'inquiry' THEN 'open' WHEN status = 'booking' THEN 'accepted' ELSE status END"); $this->addSql('ALTER TABLE accommodation_booking CHANGE type type VARCHAR(20) NOT NULL'); } public function down(Schema $schema): void { $this->addSql("UPDATE accommodation_booking SET status = CASE WHEN status IN ('draft', 'discarded') THEN status WHEN type = 'inquiry' AND status = 'open' THEN 'inquiry' ELSE 'booking' END"); $this->addSql('ALTER TABLE accommodation_booking DROP type'); } }