Files
thetool/db/migrations/20231010161225_add_voiceplan_zone.php
2023-11-14 20:15:06 +01:00

71 lines
3.2 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddVoiceplanZone extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("Voiceplanzone");
$table->addColumn("voiceplan_id", "integer", ["null" => false]);
$table->addColumn("extref", "string", ["null" => true, "default" => null, "limit" => 64]);
$table->addColumn("name", "string", ["null" => false, "limit" => 255]);
$table->addColumn("purchase_price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
$table->addColumn("price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
$table->addColumn("increment_first", "integer", ["null" => false, "default" => 60]);
$table->addColumn("increment", "integer", ["null" => false, "default" => 30]);
$table->addColumn("create_by", "integer", ["null" => false]);
$table->addColumn("edit_by", "integer", ["null" => false]);
$table->addColumn("create", "integer", ["null" => false]);
$table->addColumn("edit", "integer", ["null" => false]);
$table->create();
$table = $this->table("Voiceplandestination");
$table->removeColumn("purchase_price");
$table->removeColumn("price");
$table->removeColumn("increment_first");
$table->removeColumn("increment");
$table->renameColumn("voiceplan_id", "voiceplanzone_id");
$table->update();
$table = $this->table("VoiceplanFile");
$table->addColumn("voiceplan_id", "integer", ["null" => false]);
$table->addColumn("file_id", "integer", ["null" => false]);
$table->addColumn("name", "string", ["null" => false, "limit" => 255]);
$table->addColumn("description", "text", ["null" => true, "default" => null]);
$table->addColumn("create_by", "integer", ["null" => false]);
$table->addColumn("edit_by", "integer", ["null" => false]);
$table->addColumn("create", "integer", ["null" => false]);
$table->addColumn("edit", "integer", ["null" => false]);
$table->create();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("VoiceplanFile")->drop()->save();
$table = $this->table("Voiceplandestination");
$table->renameColumn("voiceplanzone_id", "voiceplan_id");
$table->addColumn("purchase_price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
$table->addColumn("price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
$table->addColumn("increment_first", "integer", ["null" => false, "default" => 1]);
$table->addColumn("increment", "integer", ["null" => false, "default" => 1]);
$table->update();
$this->table("Voiceplanzone")->drop()->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}