Skip to content

Commit

Permalink
Add if statement just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Nov 12, 2024
1 parent c2b4c44 commit e3f688c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/Migration/Version1Date20241111144800.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
");
}
}
}

0 comments on commit e3f688c

Please sign in to comment.