Files
thetool/db/migrations/20241210131036_create_construction_consent_project.php
2024-12-13 12:02:06 +01:00

142 lines
8.6 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateConstructionConsentProject extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$ccp = $this->table("ConstructionConsentProject");
$ccp->addColumn("name", "string", ["null" => false, "limit" => 255]);
$ccp->addColumn("sender_name", "string", ["null" => false, "limit" => 64]);
$ccp->addColumn("sender_email", "string", ["null" => false, "limit" => 64]);
$ccp->addColumn("sender_reply_to", "string", ["null" => false, "limit" => 64]);
$ccp->addColumn("email", "string", ["null" => false, "limit" => 64]);
$ccp->addColumn("phone", "string", ["null" => false, "limit" => 64]);
$ccp->addColumn("note", "text", ["null" => true, "default" => null]);
$ccp->addColumn("create_by", "integer", ["null" => false]);
$ccp->addColumn("edit_by", "integer", ["null" => false]);
$ccp->addColumn("create", "integer", ["null" => false]);
$ccp->addColumn("edit", "integer", ["null" => false]);
$ccp->create();
$ccn = $this->table("ConstructionConsentNetwork");
$ccn->addColumn("constructionconsentproject_id", "integer", ["null" => false]);
$ccn->addColumn("adb_netzgebiet_id", "integer", ["null" => false]);
$ccn->addColumn("create_by", "integer", ["null" => false]);
$ccn->addColumn("edit_by", "integer", ["null" => false]);
$ccn->addColumn("create", "integer", ["null" => false]);
$ccn->addColumn("edit", "integer", ["null" => false]);
$ccn->create();
$cc = $this->table("ConstructionConsent");
$cc->addColumn("constructionconsentproject_id", "integer", ["null" => false, "after" => "id"]);
$cc->addColumn("name", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "object_type"]);
$cc->addColumn("kg", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "ez"]);
$cc->addColumn("gst", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "kg"]);
$cc->addColumn("gstnr", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "gst"]);
$cc->addColumn("usage_length", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "gstnr"]);
$cc->addColumn("usage_pipe_on_plot", "integer", ["null" => false, "default" => 0, "after" => "usage_length"]);
$cc->addColumn("usage_pipe_in_building", "integer", ["null" => false, "default" => 0, "after" => "usage_pipe_on_plot"]);
$cc->addColumn("usage_manhole", "integer", ["null" => false, "default" => 0, "after" => "usage_pipe_in_building"]);
$cc->addColumn("usage_owner", "integer", ["null" => false, "default" => 0, "after" => "usage_manhole"]);
$cc->addColumn("result_text", "text", ["null" => true, "default" => null, "after" => "result"]);
$cc->addColumn("note", "text", ["null" => true, "default" => null, "after" => "result_text"]);
$cc->removeColumn("owner_name");
$cc->removeColumn("owner_street");
$cc->removeColumn("owner_zip");
$cc->removeColumn("owner_city");
$cc->removeColumn("owner_country");
$cc->removeColumn("owner_phone");
$cc->removeColumn("owner_fax");
$cc->removeColumn("owner_email");
$cc->update();
$cco = $this->table("ConstructionConsentOwner");
$cco->addColumn("constructionconsent_id", "integer", ["null" => false]);
$cco->addColumn("owner_name", "string", ["null" => true, "default" => null, "limit" => "255"]);
$cco->addColumn("owner_street", "string", ["null" => true, "default" => null, "limit" => "64"]);
$cco->addColumn("owner_zip", "string", ["null" => true, "default" => null, "limit" => "32"]);
$cco->addColumn("owner_city", "string", ["null" => true, "default" => null, "limit" => "64"]);
$cco->addColumn("owner_country", "string", ["null" => true, "default" => null, "limit" => "64"]);
$cco->addColumn("owner_phone", "string", ["null" => true, "default" => null, "limit" => "64"]);
$cco->addColumn("owner_fax", "string", ["null" => true, "default" => null, "limit" => "64"]);
$cco->addColumn("owner_email", "string", ["null" => true, "default" => null, "limit" => "64"]);
$cco->addColumn("status", "enum", ["null" => false, "default" => "new", "values" => "new,requested,answered"]);
$cco->addColumn("result", "enum", ["null" => true, "default" => null, "values" => "success,failure"]);
$cco->addColumn("create_by", "integer", ["null" => false]);
$cco->addColumn("edit_by", "integer", ["null" => false]);
$cco->addColumn("create", "integer", ["null" => false]);
$cco->addColumn("edit", "integer", ["null" => false]);
$cco->create();
$ccj = $this->table("ConstructionConsentJournal");
$ccj->addColumn("constructionconsent_id", "integer", ["null" => false]);
$ccj->addColumn("type", "string", ["null" => false]);
$ccj->addColumn("value", "string", ["null" => false, "limit" => 64]);
$ccj->addColumn("text", "string", ["null" => false, "limit" => 64]);
$ccj->addColumn("create_by", "integer", ["null" => false]);
$ccj->addColumn("edit_by", "integer", ["null" => false]);
$ccj->addColumn("create", "integer", ["null" => false]);
$ccj->addColumn("edit", "integer", ["null" => false]);
$ccj->create();
$ccf = $this->table("ConstructionConsentFile");
$ccf->addColumn("constructionconsent_id", "integer", ["null" => false]);
$ccf->addColumn("file_id", "integer", ["null" => false]);
$ccf->addColumn("filename", "string", ["null" => false]);
$ccf->addColumn("create_by", "integer", ["null" => false]);
$ccf->addColumn("edit_by", "integer", ["null" => false]);
$ccf->addColumn("create", "integer", ["null" => false]);
$ccf->addColumn("edit", "integer", ["null" => false]);
$ccf->create();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("ConstructionConsentFile")->drop()->save();
$this->table("ConstructionConsentJournal")->drop()->save();
$this->table("ConstructionConsentOwner")->drop()->save();
$this->table("ConstructionConsentNetwork")->drop()->save();
$this->table("ConstructionConsentProject")->drop()->save();
$cc = $this->table("ConstructionConsent");
$cc->removeColumn("constructionconsentproject_id");
$cc->removeColumn("name");
$cc->removeColumn("kg");
$cc->removeColumn("gst");
$cc->removeColumn("gstnr");
$cc->removeColumn("usage_length");
$cc->removeColumn("usage_pipe_on_plot");
$cc->removeColumn("usage_pipe_in_building");
$cc->removeColumn("usage_manhole");
$cc->removeColumn("usage_owner");
$cc->removeColumn("result_text");
$cc->removeColumn("note");
$cc->addColumn("owner_name", "string", ["null" => true, "default" => null, "limit" => "255", "after" => "ez"]);
$cc->addColumn("owner_street", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_name"]);
$cc->addColumn("owner_zip", "string", ["null" => true, "default" => null, "limit" => "32", "after" => "owner_street"]);
$cc->addColumn("owner_city", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_zip"]);
$cc->addColumn("owner_country", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_city"]);
$cc->addColumn("owner_phone", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_country"]);
$cc->addColumn("owner_fax", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_phone"]);
$cc->addColumn("owner_email", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_fax"]);
$cc->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
}