Files
thetool/db/migrations/20260126120000_warehousearticle_rename_revenueaccount_to_vatgroupid.php
2026-01-27 09:57:37 +00:00

34 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class WarehousearticleRenameRevenueaccountToVatgroupid extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$this->execute("ALTER TABLE WarehouseArticle CHANGE revenueAccount vatgroup_id INT(11) NOT NULL DEFAULT 2");
$this->execute("UPDATE WarehouseArticle SET vatgroup_id = CASE
WHEN vatgroup_id = 0 THEN 2
WHEN vatgroup_id = 1 THEN 3
ELSE vatgroup_id
END");
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->execute("UPDATE WarehouseArticle SET vatgroup_id = CASE
WHEN vatgroup_id = 2 THEN 0
WHEN vatgroup_id = 3 THEN 1
ELSE vatgroup_id
END");
$this->execute("ALTER TABLE WarehouseArticle CHANGE vatgroup_id revenueAccount INT(11) NOT NULL DEFAULT 0");
}
}
}