Update 20250901410000_workorder_rename.php
This commit is contained in:
@@ -4,78 +4,80 @@ declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class WorkorderRename extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$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();
|
||||
final class WorkorderRename extends AbstractMigration {
|
||||
public function up(): void {
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
|
||||
$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();
|
||||
$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->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();
|
||||
$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();
|
||||
|
||||
$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();
|
||||
$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
|
||||
{
|
||||
$tenantConfigTable = $this->table('WorkorderTenantConfig');
|
||||
$tenantConfigTable->removeColumn('civilEngineeringDocsRequired')->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 = $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();
|
||||
$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();
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user