getEnvironment() == "thetool") { $this->table('RMLWorkorder')->rename('Workorder')->save(); $this->table('RMLWorkorderCompany')->rename('WorkorderCompany')->save(); $this->table('RMLWorkorderDocumentation')->rename('WorkorderDocumentation')->save(); $this->table('RMLWorkorderJournal')->rename('WorkorderJournal')->save(); $this->table('RMLWorkorderTenantConfig')->rename('WorkorderTenantConfig')->save(); $workorderTable = $this->table('Workorder'); $workorderTable->addColumn('civilEngineeringCompanyId', 'integer', ['null' => true, 'default' => null, 'after' => 'companyId', 'comment' => 'Company assigned for civil engineering task']) ->addColumn('originalCompanyId', 'integer', ['null' => true, 'default' => null, 'after' => 'civilEngineeringCompanyId', 'comment' => 'Stores the companyId before assigning to civil engineering']) ->addIndex(['civilEngineeringCompanyId'], ['name' => 'civilEngineeringCompanyId_idx']) ->addIndex(['originalCompanyId'], ['name' => 'originalCompanyId_idx']) ->save(); $workorderTable->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(); $tenantConfigTable = $this->table('WorkorderTenantConfig'); $tenantConfigTable->addColumn('civilEngineeringDocsRequired', 'boolean', ['default' => false, 'null' => false, 'after' => 'workorderCreationFilters', 'comment' => 'If true, civil engineering company must upload docs to complete task']) ->save(); } } public function down(): void { if ($this->getEnvironment() == "thetool") { $tenantConfigTable = $this->table('WorkorderTenantConfig'); $tenantConfigTable->removeColumn('civilEngineeringDocsRequired')->save(); $workorderTable = $this->table('Workorder'); $workorderTable->changeColumn('status', 'enum', [ 'values' => [ 'new', 'assigned', 'scheduled', 'correction_requested', 'intervention_required', 'problem_solved', 'documented', 'completed', 'cancelled' ], 'default' => 'new', 'null' => false ])->save(); $workorderTable->removeColumn('civilEngineeringCompanyId') ->removeColumn('originalCompanyId') ->removeIndexByName('civilEngineeringCompanyId_idx') ->removeIndexByName('originalCompanyId_idx') ->save(); $this->table('Workorder')->rename('RMLWorkorder')->save(); $this->table('WorkorderCompany')->rename('RMLWorkorderCompany')->save(); $this->table('WorkorderDocumentation')->rename('RMLWorkorderDocumentation')->save(); $this->table('WorkorderJournal')->rename('RMLWorkorderJournal')->save(); $this->table('WorkorderTenantConfig')->rename('RMLWorkorderTenantConfig')->save(); } } }