overhauled workorder module

This commit is contained in:
Luca Haid
2025-10-08 13:18:48 +02:00
parent 200226a4bd
commit 2ce870746b
9 changed files with 314 additions and 50 deletions
@@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class WorkorderAddStatusesAndConfigAndPermission extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() !== 'thetool') {
return;
}
$this->table('Workorder')
->changeColumn('status', 'enum', [
'values' => [
'new',
'assigned',
'scheduled',
'correction_requested',
'intervention_required',
'civil_engineering_required',
'civil_engineering_completed',
'problem_solved',
'documented',
'completed',
'cancelled',
'archived',
'charged'
],
'default' => 'new',
'null' => false,
])
->save();
$workorderTenantConfigTable = $this->table('WorkorderTenantConfig');
if (!$workorderTenantConfigTable->hasColumn('workorderActiveFilters'))
$workorderTenantConfigTable->addColumn('workorderActiveFilters', 'text', [
'null' => true,
'default' => null,
'limit' => \Phinx\Db\Adapter\MysqlAdapter::TEXT_LONG,
])
->save();
$workerPermissionTable = $this->table('WorkerPermission');
if (!$workerPermissionTable->hasColumn('canRMLCompanyManager'))
$workerPermissionTable->addColumn('canRMLCompanyManager', 'enum', [
'values' => ['false', 'true'],
'null' => false,
'default' => 'false',
])
->save();
}
public function down(): void
{
if ($this->getEnvironment() !== 'thetool') {
return;
}
$this->table('Workorder')
->changeColumn('status', 'enum', [
'values' => [
'new',
'assigned',
'scheduled',
'correction_requested',
'intervention_required',
'civil_engineering_required',
'civil_engineering_completed',
'problem_solved',
'documented',
'completed',
'cancelled'
],
'default' => 'new',
'null' => false,
])
->save();
$workorderTenantConfigTable = $this->table('WorkorderTenantConfig');
if ($workorderTenantConfigTable->hasColumn('workorderActiveFilters'))
$workorderTenantConfigTable->removeColumn('workorderActiveFilters')->save();
$workerPermissionTable = $this->table('WorkerPermission');
if ($workerPermissionTable->hasColumn('canRMLCompanyManager'))
$workerPermissionTable->removeColumn('canRMLCompanyManager')->save();
}
}