58 lines
2.4 KiB
PHP
58 lines
2.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateVatTables extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$table = $this->table("Vatgroup");
|
|
$table->addColumn("name", "string", ["null" => false, "limit" => 255]);
|
|
$table->addColumn("default", "string", ["null" => false, "default" => 0, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]);
|
|
$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->save();
|
|
|
|
|
|
$table = $this->table("Vatrate");
|
|
$table->addColumn("vatgroup_id", "integer", ["null" => false]);
|
|
$table->addColumn("area", "enum", ["null" => false, "values" => "domestic,eu,other"]);
|
|
$table->addColumn("account", "integer", ["null" => false]);
|
|
$table->addColumn("legacy_account", "integer", ["null" => true, "default" => null]);
|
|
$table->addColumn("rate", "decimal", ["null" => false, "precision" => 6, "scale" => 2]);
|
|
$table->addColumn("taxcode", "integer", ["null" => true, "default" => null]);
|
|
$table->addColumn("invoice_text", "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();
|
|
|
|
$table = $this->table("Product");
|
|
$table->addColumn("vatgroup_id", "integer", ["null" => false, "default" => 1, "after" => "price_setup"]);
|
|
$table->save();
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$this->table("Product")->removeColumn("vatgroup_id")->save();
|
|
$this->table("Vatrate")->drop()->save();
|
|
$this->table("Vatgroup")->drop()->save();
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
}
|