Files
thetool/db/migrations/20250121164455_construction_consent_change_status_and_result.php
2025-01-21 22:54:15 +01:00

78 lines
4.0 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class ConstructionConsentChangeStatusAndResult extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("ConstructionConsent");
$table->changeColumn("status", "enum", ["null" => true, "default" => null, "values" => "new,sent,returned,outstanding"]);
$table->changeColumn("result", "enum", ["null" => true, "default" => null, "values" => "open,accepted,denied,unresolvable"]);
$table->addColumn("inspection_date_planner", "integer", ["null" => true, "default" => null, "after" => "result_text"]);
$table->addColumn("inspection_date_electrician", "integer", ["null" => true, "default" => null, "after" => "inspection_date_planner"]);
$table->addColumn("conduit_installed_building", "integer", ["null" => true, "default" => null, "after" => "inspection_date_electrician"]);
$table->addColumn("conduit_installed_ftu", "integer", ["null" => true, "default" => null, "after" => "conduit_installed_building"]);
$table->addColumn("inhouse_cabling", "integer", ["null" => true, "default" => null, "after" => "conduit_installed_ftu"]);
$table->update();
$this->execute("UPDATE ConstructionConsentOwner SET status=NULL, result=NULL");
$cco = $this->table("ConstructionConsentOwner");
$cco->changeColumn("status", "enum", ["null" => true, "default" => null, "values" => "new,sent,returned,outstanding"]);
$cco->changeColumn("result", "enum", ["null" => true, "default" => null, "values" => "open,accepted,denied,unresolvable"]);
$cco->update();
$this->execute("UPDATE ConstructionConsentOwner SET status='new', result='open'");
$cco->changeColumn("status", "enum", ["null" => true, "default" => "new", "values" => "new,sent,returned,outstanding"]);
$cco->changeColumn("result", "enum", ["null" => true, "default" => "open", "values" => "open,accepted,denied,unresolvable"]);
$cco->update();
$ccj = $this->table("ConstructionConsentJournal");
$ccj->removeColumn("type");
$ccj->removeColumn("value");
$ccj->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->execute("UPDATE ConstructionConsent SET status=NULL, result=NULL");
$table = $this->table("ConstructionConsent");
$table->changeColumn("result", "enum", ["null" => true, "default" => null, "values" => "new,requested,answered"]);
$table->changeColumn("status", "enum", ["null" => true, "default" => null, "values" => "success,failure"]);
$table->removeColumn("inspection_date_planner");
$table->removeColumn("inspection_date_electrician");
$table->removeColumn("conduit_installed_building");
$table->removeColumn("conduit_installed_ftu");
$table->removeColumn("inhouse_cabling");
$table->update();
$cco = $this->table("ConstructionConsentOwner");
$this->execute("UPDATE ConstructionConsentOwner SET status=NULL, result=NULL");
$cco->changeColumn("result", "enum", ["null" => true, "default" => null, "values" => "new,requested,answered"]);
$cco->changeColumn("status", "enum", ["null" => true, "default" => null, "values" => "success,failure"]);
$cco->update();
$ccj = $this->table("ConstructionConsentJournal");
$ccj->addColumn("type", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "constructionconsent_id"]);
$ccj->addColumn("value", "string", ["null" => true, "default" => null, "limit" => 64, "after" => "type"]);
$ccj->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
}