feat: refactored accommodation booking status model
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260819120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Split the ambiguous Offen status into Angefragt and Offen, and turn the booking type into an immutable origin';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// Offen used to mean both "inquiry just arrived" and "offer is out with the customer",
|
||||
// told apart only by the access link. An Offen row without a link is exactly the
|
||||
// former case and becomes Angefragt; rows with a link are genuinely awaiting the
|
||||
// customer's acceptance and keep their status.
|
||||
$this->addSql("UPDATE accommodation_booking SET status = 'requested' WHERE status = 'open' AND access_link_issued_at IS NULL");
|
||||
|
||||
// The type described the lifecycle a second time and contradicted the status once an
|
||||
// offer had been accepted. It now records only where the booking came from, which is
|
||||
// true at every point of its life: an old `inquiry` went through an offer however far
|
||||
// it got, an old `booking` was placed directly.
|
||||
$this->addSql('ALTER TABLE accommodation_booking CHANGE type origin VARCHAR(20) NOT NULL');
|
||||
$this->addSql("UPDATE accommodation_booking SET origin = 'offer' WHERE origin = 'inquiry'");
|
||||
$this->addSql("UPDATE accommodation_booking SET origin = 'direct' WHERE origin = 'booking'");
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("UPDATE accommodation_booking SET origin = 'inquiry' WHERE origin = 'offer'");
|
||||
$this->addSql("UPDATE accommodation_booking SET origin = 'booking' WHERE origin = 'direct'");
|
||||
$this->addSql('ALTER TABLE accommodation_booking CHANGE origin type VARCHAR(20) NOT NULL');
|
||||
$this->addSql("UPDATE accommodation_booking SET status = 'open' WHERE status = 'requested'");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user