overhauled workorder module

This commit is contained in:
Luca Haid
2025-10-08 14:32:04 +02:00
parent 2ce870746b
commit 41f941cfbc
5 changed files with 95 additions and 19 deletions
@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class WorkorderAddInProgress extends AbstractMigration {
public function up(): void {
if ($this->getEnvironment() !== 'thetool') return;
$this->table('Workorder')
->changeColumn('status', 'enum', [
'values' => [
'new',
'assigned',
'scheduled',
'in_progress',
'correction_requested',
'intervention_required',
'civil_engineering_required',
'civil_engineering_completed',
'problem_solved',
'documented',
'completed',
'cancelled',
'archived',
'charged'
],
'default' => 'new',
'null' => false,
])
->save();
// Update existing Workorders that are assigned or scheduled and already have documentation.
$this->execute("
UPDATE Workorder w
SET w.status = 'in_progress'
WHERE w.status IN ('assigned', 'scheduled')
AND EXISTS (
SELECT 1
FROM WorkorderDocumentation wd
WHERE wd.workorderId = w.id
)
");
}
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',
'archived',
'charged'
],
'default' => 'new',
'null' => false,
])
->save();
}
}