From e726d4f8f3636ab80c4e37db5b390c5125d0f2aa Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Thu, 18 Aug 2022 07:54:02 +0000
Subject: [PATCH] migration 1.254: delete all data from opengraphdata table
 before altering it, fixes #1445

Closes #1445

Merge request studip/studip!899
---
 db/migrations/1.254_hash_opengraph_table.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/db/migrations/1.254_hash_opengraph_table.php b/db/migrations/1.254_hash_opengraph_table.php
index 886214668c4..9d8ede59b79 100644
--- a/db/migrations/1.254_hash_opengraph_table.php
+++ b/db/migrations/1.254_hash_opengraph_table.php
@@ -3,6 +3,10 @@ class HashOpengraphTable extends Migration
 {
     public function up()
     {
+        //Prevent duplicate entries in one of the following queries
+        //by deleting all entries in the opengraphdata table:
+        DBManager::get()->exec("DELETE FROM `opengraphdata`");
+
         $query = "ALTER TABLE `opengraphdata`
                   ADD COLUMN `hash` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' AFTER `opengraph_id`";
         DBManager::get()->exec($query);
-- 
GitLab