overhauled workorder module
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user