fixed migration

This commit is contained in:
2025-08-05 15:10:50 +02:00
parent dff3a4f5b8
commit 41a25258e5
2 changed files with 44 additions and 14 deletions

View File

@@ -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;

View File

@@ -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();
}
}
}
}