feat: accommodation booking type and status as dedicated properties
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260806120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Split the accommodation booking status into a status and a type';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user