Merge branch 'warehouse-order-improvements' into 'master'
Updated WarehouseOrder and WarehouseOrderRequest See merge request fronk/thetool!1075
This commit is contained in:
61
db/migrations/20250306100000_warehouse_modify_13.php
Normal file
61
db/migrations/20250306100000_warehouse_modify_13.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class WarehouseModify13 extends AbstractMigration {
|
||||
public function up(): void {
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
// Add status column to WarehouseOrder
|
||||
$table = $this->table("WarehouseOrder");
|
||||
$table->addColumn("status", "enum", [
|
||||
'values' => ['new','accepted','ordered','sent','partiallyDelivered','fullyDelivered','cancelled'],
|
||||
'null' => true,
|
||||
'default' => null
|
||||
])
|
||||
->save();
|
||||
|
||||
// Recreate WarehouseOrderRequest
|
||||
if ($this->hasTable('WarehouseOrderRequest')) {
|
||||
$this->table('WarehouseOrderRequest')->drop()->save();
|
||||
}
|
||||
|
||||
$orderRequest = $this->table('WarehouseOrderRequest', ['id' => 'id', 'signed' => false]);
|
||||
$orderRequest->addColumn('purpose', 'text')
|
||||
->addColumn('positions', 'text')
|
||||
->addColumn('note', 'text', ['null' => true])
|
||||
->addColumn('linkedOrderIds', 'text', ['null' => true])
|
||||
->addColumn('cancelled', 'integer', ['default' => 0])
|
||||
->addColumn('create', 'integer')
|
||||
->addColumn('createBy', 'integer')
|
||||
->create();
|
||||
|
||||
// Create WarehouseLog if not exists
|
||||
if (!$this->hasTable('WarehouseLog')) {
|
||||
$log = $this->table('WarehouseLog', ['id' => 'id', 'signed' => false]);
|
||||
$log->addColumn('table', 'string', ['limit' => 255])
|
||||
->addColumn('rowId', 'integer')
|
||||
->addColumn('type', 'enum', ['values' => ['noChanges','statusChange']])
|
||||
->addColumn('fileIds', 'text', ['null' => true])
|
||||
->addColumn('message', 'string', ['limit' => 255])
|
||||
->addColumn('create', 'integer')
|
||||
->addColumn('createBy', 'integer')
|
||||
->addIndex(['rowId'], ['name' => 'orderId'])
|
||||
->addIndex(['createBy'], ['name' => 'createBy'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
// Remove status column
|
||||
$table = $this->table("WarehouseOrder");
|
||||
$table->removeColumn("status")
|
||||
->save();
|
||||
|
||||
// Drop new tables
|
||||
$this->table('WarehouseOrderRequest')->drop()->save();
|
||||
$this->table('WarehouseLog')->drop()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user