Files
thetool/db/migrations/20240620160026_create_billing.php
2024-07-06 18:37:40 +02:00

68 lines
3.8 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateBilling extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("Billing");
$table->addColumn("invoice_id", "integer", ["null" => true, "default" => null]);
$table->addColumn("contract_id", "integer", ["null" => false]);
$table->addColumn("start_date", "date", ["null" => false]);
$table->addColumn("end_date", "date", ["null" => false]);
$table->addColumn("owner_id", "integer", ["null" => false]);
$table->addColumn("billingaddress_id", "integer", ["null" => false]);
$table->addColumn("customer_number", "integer", ["null" => false]);
$table->addColumn("company", "string", ["null" => true, "default" => null, "length" => 1024]);
$table->addColumn("firstname", "string", ["null" => true, "default" => null, "length" => 1024]);
$table->addColumn("lastname", "string", ["null" => true, "default" => null, "length" => 1024]);
$table->addColumn("street", "string", ["null" => false, "length" => 1024]);
$table->addColumn("zip", "string", ["null" => false, "length" => 1024]);
$table->addColumn("city", "string", ["null" => false, "length" => 1024]);
$table->addColumn("country", "string", ["null" => true, "default" => null, "length" => 1024]);
$table->addColumn("email", "string", ["null" => true, "default" => null, "length" => 1024]);
$table->addColumn("uid", "string", ["null" => true, "default" => null, "length" => 1024]);
$table->addColumn("billing_type", "enum", ["null" => false, "values" => "invoice,sepa"]);
$table->addColumn("billing_delivery", "enum", ["null" => false, "values" => "email,paper"]);
$table->addColumn("bank_account_bank", "string", ["null" => true, "default" => null, "length" => 255]);
$table->addColumn("bank_account_owner", "string", ["null" => true, "default" => null, "length" => 255]);
$table->addColumn("bank_account_iban", "string", ["null" => true, "default" => null, "length" => 255]);
$table->addColumn("bank_account_bic", "string", ["null" => true, "default" => null, "length" => 255]);
$table->addColumn("matchcode", "string", ["null" => true, "default" => null, "length" => 255]);
$table->addColumn("product_id", "integer", ["null" => false]);
$table->addColumn("product_name", "string", ["null" => false, "length" => 255]);
$table->addColumn("product_info", "text", ["null" => true, "default" => null]);
$table->addColumn("amount", "decimal", ["null" => false, "precision" => 9, "scale" => 6]);
$table->addColumn("price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
$table->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]);
$table->addColumn("vatrate", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
$table->addColumn("billing_period", "integer", ["null" => false, "default" => 0]);
$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("Billing")->drop()->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}