From 41a25258e53aafdbaa3009cdc7b9b4e3bbadae70 Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Tue, 5 Aug 2025 15:10:50 +0200 Subject: [PATCH] fixed migration --- ...0250723204001_CreateRmlWorkorderTables.php | 14 ------ ...000_alter_workorder_and_create_journal.php | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 14 deletions(-) delete mode 100644 db/migrations/20250723204001_CreateRmlWorkorderTables.php create mode 100644 db/migrations/20250805150000_alter_workorder_and_create_journal.php diff --git a/db/migrations/20250723204001_CreateRmlWorkorderTables.php b/db/migrations/20250723204001_CreateRmlWorkorderTables.php deleted file mode 100644 index 901b22926..000000000 --- a/db/migrations/20250723204001_CreateRmlWorkorderTables.php +++ /dev/null @@ -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; \ No newline at end of file diff --git a/db/migrations/20250805150000_alter_workorder_and_create_journal.php b/db/migrations/20250805150000_alter_workorder_and_create_journal.php new file mode 100644 index 000000000..a00cc8ddb --- /dev/null +++ b/db/migrations/20250805150000_alter_workorder_and_create_journal.php @@ -0,0 +1,44 @@ +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(); + } + } + } +}