From 0b60240a60a70b26e0bb55eb4f9f333835898a62 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 29 Oct 2024 12:45:30 +0000
Subject: [PATCH] provide migration that removes the invalid entries from
 folders table, re #4008, fixes #4777

Closes #4777

Merge request studip/studip!3572
---
 .../5.3.25_remove_bogus_folders_biest_4008.php | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 db/migrations/5.3.25_remove_bogus_folders_biest_4008.php

diff --git a/db/migrations/5.3.25_remove_bogus_folders_biest_4008.php b/db/migrations/5.3.25_remove_bogus_folders_biest_4008.php
new file mode 100644
index 00000000000..14fa348b239
--- /dev/null
+++ b/db/migrations/5.3.25_remove_bogus_folders_biest_4008.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/4777
+ */
+return new class extends Migration
+{
+    public function description()
+    {
+        return 'Removes the invalid entries from folder table (see BIEST#4008)';
+    }
+
+    protected function up()
+    {
+        $query = "DELETE FROM `folders`
+                  WHERE `folder_type` IN ('course', 'user')";
+        DBManager::get()->exec($query);
+    }
+};
-- 
GitLab