Files
thetool/db/migrations/20250805170206_billing_add_payment_due.php
2025-08-05 19:32:50 +02:00

78 lines
2.7 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class BillingAddPaymentDue extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$billing = $this->table("Billing");
$billing->addColumn("fibu_payment_due", "integer", ["null" => true, "default" => null, "after" => "fibu_account_number"]);
$billing->addColumn("fibu_payment_skonto", "integer", ["null" => false, "default" => 0, "after" => "fibu_payment_due"]);
$billing->addColumn("fibu_payment_skonto_rate", "integer", ["null" => false, "default" => 0, "after" => "fibu_payment_skonto"]);
$billing->addIndex("invoice_id");
$billing->addIndex("contract_id");
$billing->addIndex("start_date");
$billing->addIndex("end_date");
$billing->update();
$bv = $this->table("BillingVoicenumber");
$bv->addIndex("contract_id");
$bv->addIndex("voicenumber");
$bv->addIndex("start_date");
$bv->addIndex("end_date");
$bv->update();
$invoice = $this->table("Invoice");
$invoice->addIndex("invoice_number");
$invoice->addIndex("invoice_date");
$invoice->addIndex("owner_id");
$invoice->addIndex("billingaddress_id");
$invoice->addIndex("customer_number");
$invoice->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("Billing")
->removeColumn("fibu_payment_skonto_rate")
->removeColumn("fibu_payment_skonto")
->removeColumn("fibu_payment_due")
->removeIndex("end_date")
->removeIndex("start_date")
->removeIndex("contract_id")
->removeIndex("invoice_id")
->update();
$this->table("BillingVoicenumber")
->removeIndex("end_date")
->removeIndex("start_date")
->removeIndex("voicenumber")
->removeIndex("contract_id")
->update();
$this->table("Invoice")
->removeIndex("customer_number")
->removeIndex("billingaddress_id")
->removeIndex("owner_id")
->removeIndex("invoice_date")
->removeIndex("invoice_number")
->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
}