Files
thetool/db/migrations/20240717144237_create_preorderstatus_flag.php
2024-07-29 14:44:08 +02:00

90 lines
3.3 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreatePreorderstatusFlag extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$psf = $this->table("PreorderStatusflag");
$psf->addColumn("code", "integer", ["null" => false]);
$psf->addColumn("name", "string", ["null" => false, "limit" => 64]);
$psf->addColumn("connection_type", "enum", ["null" => false, "values" => "all,single,multi", "default" => "all"]);
$psf->addColumn("create_by", "integer", ["null" => false]);
$psf->addColumn("edit_by", "integer", ["null" => false]);
$psf->addColumn("create", "integer", ["null" => false]);
$psf->addColumn("edit", "integer", ["null" => false]);
$psf->create();
$psf->insert([
[
"code" => 145,
"name" => "Installation kit picked up or shipped",
"connection_type" => "all",
"create_by" => 1,
"edit_by" => 1,
"create" => date("U"),
"edit" => date("U")
],
[
"code" => 150,
"name" => "Borderpoint connected",
"connection_type" => "all",
"create_by" => 1,
"edit_by" => 1,
"create" => date("U"),
"edit" => date("U")
],
[
"code" => 200,
"name" => "Conduit in building",
"connection_type" => "all",
"create_by" => 1,
"edit_by" => 1,
"create" => date("U"),
"edit" => date("U")
],
[
"code" => 242,
"name" => "Inhouse cabeling finished",
"connection_type" => "all",
"create_by" => 1,
"edit_by" => 1,
"create" => date("U"),
"edit" => date("U")
],
])->save();
$psfv = $this->table("PreorderStatusflagValue");
$psfv->addColumn("preorder_id", "integer", ["null" => false]);
$psfv->addColumn("flag_id", "integer", ["null" => false]);
$psfv->addColumn("value", "integer", ["null" => false]);
$psfv->addColumn("create_by", "integer", ["null" => false]);
$psfv->addColumn("edit_by", "integer", ["null" => false]);
$psfv->addColumn("create", "integer", ["null" => false]);
$psfv->addColumn("edit", "integer", ["null" => false]);
$psfv->addIndex("preorder_id");
$psfv->addIndex(["preorder_id", "flag_id"]);
$psfv->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("PreorderStatusflagValue")->drop()->save();
$this->table("PreorderStatusflag")->drop()->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}