From e3f688c6bba58663fafa4c58e2c671e512136895 Mon Sep 17 00:00:00 2001 From: Wilco Louwerse Date: Tue, 12 Nov 2024 15:34:49 +0100 Subject: [PATCH] Add if statement just in case --- lib/Migration/Version1Date20241111144800.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Migration/Version1Date20241111144800.php b/lib/Migration/Version1Date20241111144800.php index b70e38f..69a8e44 100644 --- a/lib/Migration/Version1Date20241111144800.php +++ b/lib/Migration/Version1Date20241111144800.php @@ -90,11 +90,21 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt * @param array $options */ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + /** + * @var ISchemaWrapper $schema + */ + $schema = $schemaClosure(); + $table = $schema->getTable('openconnector_synchronization_contracts'); + // Step 2: Copy data from old columns to new columns - $this->connection->executeQuery(" + if ($table->hasColumn('origin_id') === true && $table->hasColumn('origin_hash') === true + && $table->hasColumn('source_id') === true && $table->hasColumn('source_hash') === true + ) { + $this->connection->executeQuery(" UPDATE openconnector_synchronization_contracts SET origin_id = source_id, origin_hash = source_hash WHERE source_id IS NOT NULL "); + } } }