36 lines
1.4 KiB
PHP
36 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260914090000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Drops booking_series.weekdays -- a series now strides from its start date';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// A recurrence rule is only a step size now (1, 7, 14 or 28 days), and every whole-week
|
|
// stride holds the weekday of the start date by construction. The column had nothing
|
|
// left to say. Existing rows need no data migration: their start_date already carries
|
|
// the weekday, and the stride reproduces it.
|
|
$this->addSql('ALTER TABLE booking_series DROP weekdays');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// Lossy on purpose, and not fixable: which weekdays a multi-day weekly series used to
|
|
// run on is gone once the column is dropped. Every restored row comes back as "[]",
|
|
// which the old code read as "every calendar day" for DAILY and "no days at all" for
|
|
// WEEKLY -- so a rolled-back weekly series would materialise nothing.
|
|
$this->addSql("ALTER TABLE booking_series ADD weekdays JSON NOT NULL DEFAULT '[]'");
|
|
$this->addSql('ALTER TABLE booking_series ALTER weekdays DROP DEFAULT');
|
|
}
|
|
}
|