fixed migration
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
-- migration.sql
|
||||
ALTER TABLE `RMLWorkorder` ADD `clusterId` INT NULL AFTER `companyId`;
|
||||
|
||||
CREATE TABLE `RMLWorkorderJournal` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`workorderId` int NOT NULL,
|
||||
`text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`fileIds` json DEFAULT NULL,
|
||||
`statusChange` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`create` int NOT NULL,
|
||||
`createBy` int NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `workorderId` (`workorderId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AlterWorkorderAndCreateJournal extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$workorder = $this->table('RMLWorkorder');
|
||||
$workorder->addColumn('clusterId', 'integer', ['null' => true, 'after' => 'companyId'])
|
||||
->addIndex(['clusterId'], ['name' => 'clusterId_idx'])
|
||||
->save();
|
||||
|
||||
if (!$this->hasTable('RMLWorkorderJournal')) {
|
||||
$journal = $this->table('RMLWorkorderJournal', ['id' => false, 'primary_key' => ['id']]);
|
||||
$journal->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
||||
->addColumn('workorderId', 'integer', ['null' => false])
|
||||
->addColumn('text', 'text', ['null' => true])
|
||||
->addColumn('fileIds', 'json', ['null' => true])
|
||||
->addColumn('statusChange', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('create', 'integer', ['null' => false])
|
||||
->addColumn('createBy', 'integer', ['null' => false])
|
||||
->addIndex(['workorderId'], ['name' => 'workorderId_idx'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
if ($this->hasTable('RMLWorkorderJournal')) {
|
||||
$this->table('RMLWorkorderJournal')->drop()->save();
|
||||
}
|
||||
|
||||
$workorder = $this->table('RMLWorkorder');
|
||||
if ($workorder->hasColumn('clusterId')) {
|
||||
$workorder->removeColumn('clusterId')->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user