59 lines
3.0 KiB
PHP
59 lines
3.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateRmlWorkorderTables extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if ($this->getEnvironment() == "thetool") {
|
|
$this->execute('DROP TABLE IF EXISTS `RMLWorkorderDocumentation`');
|
|
$this->execute('DROP TABLE IF EXISTS `RMLWorkorderCompany`');
|
|
$this->execute('DROP TABLE IF EXISTS `RMLWorkorder`');
|
|
|
|
$workorder = $this->table('RMLWorkorder', ['id' => false, 'primary_key' => ['id']]);
|
|
$workorder->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
|
->addColumn('preorderId', 'integer', ['null' => false])
|
|
->addColumn('companyId', 'integer', ['null' => true])
|
|
->addColumn('status', 'string', ['limit' => 50, 'null' => false, 'default' => 'new'])
|
|
->addColumn('assignmentDate', 'integer', ['null' => true])
|
|
->addColumn('deadlineDate', 'integer', ['null' => true])
|
|
->addColumn('appointmentDate', 'integer', ['null' => true])
|
|
->addColumn('create', 'integer', ['null' => false])
|
|
->addColumn('createBy', 'integer', ['null' => false])
|
|
->addIndex(['preorderId'], ['name' => 'preorderId_idx'])
|
|
->addIndex(['companyId'], ['name' => 'companyId_idx'])
|
|
->addIndex(['status'], ['name' => 'status_idx'])
|
|
->create();
|
|
|
|
$company = $this->table('RMLWorkorderCompany', ['id' => false, 'primary_key' => ['id']]);
|
|
$company->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
|
->addColumn('addressId', 'integer', ['null' => false])
|
|
->addColumn('name', 'string', ['limit' => 255, 'null' => false])
|
|
->addColumn('create', 'integer', ['null' => false])
|
|
->addColumn('createBy', 'integer', ['null' => false])
|
|
->create();
|
|
|
|
$documentation = $this->table('RMLWorkorderDocumentation', ['id' => false, 'primary_key' => ['id']]);
|
|
$documentation->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
|
->addColumn('workorderId', 'integer', ['null' => false])
|
|
->addColumn('fileId', 'integer', ['null' => false])
|
|
->addColumn('description', 'text', ['null' => true])
|
|
->addColumn('documentType', 'string', ['limit' => 100, 'null' => false])
|
|
->addColumn('create', 'integer', ['null' => false])
|
|
->addColumn('createBy', 'integer', ['null' => false])
|
|
->addIndex(['workorderId'], ['name' => 'workorderId_idx'])
|
|
->create();
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if ($this->getEnvironment() == "thetool") {
|
|
$this->table('RMLWorkorderDocumentation')->drop()->save();
|
|
$this->table('RMLWorkorderCompany')->drop()->save();
|
|
$this->table('RMLWorkorder')->drop()->save();
|
|
}
|
|
}
|
|
} |