40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Replaces the staffing matrix's split flag with one flag per ski level.
|
|
*
|
|
* A split row takes over every level it has, so it keeps planning the same assignments. The way
|
|
* back folds the two flags into one, which loses a row that takes over one level of two.
|
|
*
|
|
* Written by hand rather than taken from doctrine:migrations:diff, which also carries the
|
|
* pre-existing drift of the dev database.
|
|
*/
|
|
final class Version20261105100000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Replace staffing_rule.split with split_beginner / split_advanced';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE staffing_rule ADD split_beginner TINYINT NOT NULL, ADD split_advanced TINYINT NOT NULL');
|
|
$this->addSql('UPDATE staffing_rule SET split_beginner = split AND ski_beginner, split_advanced = split AND ski_advanced');
|
|
$this->addSql('ALTER TABLE staffing_rule DROP split');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE staffing_rule ADD split TINYINT NOT NULL');
|
|
$this->addSql('UPDATE staffing_rule SET split = split_beginner OR split_advanced');
|
|
$this->addSql('ALTER TABLE staffing_rule DROP split_beginner, DROP split_advanced');
|
|
}
|
|
}
|