Merge branch 'fronkdev' into 'master'

Added Journal/History/Contacts to ConstructionConsent

See merge request fronk/thetool!938
This commit is contained in:
Frank Schubert
2025-01-21 21:55:13 +00:00
14 changed files with 1143 additions and 28 deletions
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateConstructionConsentHistoryAndContact extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$cch = $this->table("ConstructionConsentHistory");
$cch->addColumn("constructionconsent_id", "integer", ["null" => false])
->addColumn("key", "string", ["null" => false, "limit" => 100])
->addColumn("old_value", "text", ["null" => true])
->addColumn("new_value", "text", ["null" => true])
->addColumn("create_by", "integer", ["null" => false])
->addColumn("edit_by", "integer", ["null" => false])
->addColumn("create", "integer", ["null" => false])
->addColumn("edit", "integer", ["null" => false]);
$cch->create();
$ccc = $this->table("ConstructionConsentContact");
$ccc->addColumn("constructionconsent_id", "integer", ["null" => false])
->addColumn("type", "enum", ["null" => false, "values" => ["contact", "property_manager", "electrician", "other"]])
->addColumn("name", "string", ["null" => true, "default" => null, "limit" => "255"])
->addColumn("street", "string", ["null" => true, "default" => null, "limit" => "64"])
->addColumn("zip", "string", ["null" => true, "default" => null, "limit" => "32"])
->addColumn("city", "string", ["null" => true, "default" => null, "limit" => "64"])
->addColumn("country", "string", ["null" => true, "default" => null, "limit" => "64"])
->addColumn("phone", "string", ["null" => true, "default" => null, "limit" => "64"])
->addColumn("fax", "string", ["null" => true, "default" => null, "limit" => "64"])
->addColumn("email", "string", ["null" => true, "default" => null, "limit" => "64"])
->addColumn("create_by", "integer", ["null" => false])
->addColumn("edit_by", "integer", ["null" => false])
->addColumn("create", "integer", ["null" => false])
->addColumn("edit", "integer", ["null" => false]);
$ccc->create();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
}
if($this->getEnvironment() == "addressdb") {
}
}
}
@@ -0,0 +1,77 @@
<?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") {
}
}
}