Files
myep-team/migrations/Version20260925120000.php
T

46 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* What it takes to provision a teamer from a received application: the applicant's gender, and the
* outcome of each of the three provisioning writes
* (.ddev/plans/application-form-teamer-provisioning.md).
*
* Emptying the table first is deliberate. gender is NOT NULL because BusPro refuses an address
* without one and Teamer::$gender is not nullable either, and the existing rows predate the
* tightened endpoint contract, so none of them carries a value. They are test submissions in dev -
* the feature has never shipped, and nothing in production is affected. Doing it here rather than
* by hand keeps it reviewable and keeps the migration replayable.
*
* Reduced to these statements by hand: the generated diff also wanted to restate the long-standing
* datetime comment drift and another branch's tables.
*/
final class Version20260925120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add gender and the provisioning state to application_form_submission';
}
public function up(Schema $schema): void
{
$this->addSql('DELETE FROM application_form_submission');
$this->addSql('ALTER TABLE application_form_submission ADD gender VARCHAR(1) NOT NULL, ADD bus_pro_address_id INT DEFAULT NULL, ADD bus_pro_person_id INT DEFAULT NULL, ADD teamer_created_at DATETIME DEFAULT NULL, ADD user_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE application_form_submission ADD CONSTRAINT FK_F47CE995A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_F47CE995A76ED395 ON application_form_submission (user_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE application_form_submission DROP FOREIGN KEY FK_F47CE995A76ED395');
$this->addSql('DROP INDEX IDX_F47CE995A76ED395 ON application_form_submission');
$this->addSql('ALTER TABLE application_form_submission DROP gender, DROP bus_pro_address_id, DROP bus_pro_person_id, DROP teamer_created_at, DROP user_id');
}
}