aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2025-07-26 09:40:57 +0200
committerDavid Siegfried <david.siegfried@uni-vechta.de>2025-07-26 07:40:57 +0000
commitedc914d898ca5ab86dab53fe059629c91fd5759b (patch)
treef30c541c710ee99d51e822e1c8a50b02ed55ccce /db
parentd83a8347ed60b06b360827dc8a1026a70815a483 (diff)
fix issues in vips migration, fixes #5380
Closes #5380 Merge request studip/studip!4392
Diffstat (limited to 'db')
-rw-r--r--db/migrations/6.0.40_add_vips_module.php11
-rw-r--r--db/migrations/6.0.52_vips_statusgruppe_user.php27
2 files changed, 36 insertions, 2 deletions
diff --git a/db/migrations/6.0.40_add_vips_module.php b/db/migrations/6.0.40_add_vips_module.php
index 8fc50c8..8fa2d21 100644
--- a/db/migrations/6.0.40_add_vips_module.php
+++ b/db/migrations/6.0.40_add_vips_module.php
@@ -238,7 +238,7 @@ class AddVipsModule extends Migration
'range_id' => $row['course_id'],
'type' => $row['type'],
'start' => strtotime($row['start']),
- 'end' => strtotime($row['end']),
+ 'end' => $row['end'] ? strtotime($row['end']) : null,
'active' => $row['active'],
'weight' => $row['weight'],
'block_id' => $row['block_id'],
@@ -323,6 +323,9 @@ class AddVipsModule extends Migration
$sql = 'INSERT INTO etask_group_members (group_id, user_id, start, end)
VALUES (:group_id, :user_id, :start, :end)';
$stmt = $db->prepare($sql);
+ $sql = 'INSERT INTO statusgruppe_user (statusgruppe_id, user_id, mkdate)
+ VALUES (:group_id, :user_id, :start)';
+ $stmt2 = $db->prepare($sql);
$data = $db->query('SELECT * FROM vips_group_member');
while ($row = $data->fetch(PDO::FETCH_ASSOC)) {
@@ -331,9 +334,13 @@ class AddVipsModule extends Migration
'group_id' => $group_id[$row['group_id']],
'user_id' => $row['user_id'],
'start' => strtotime($row['start']),
- 'end' => strtotime($row['end'])
+ 'end' => $row['end'] ? strtotime($row['end']) : null
];
$stmt->execute($values);
+
+ if ($row['end'] === null) {
+ $stmt2->execute($values);
+ }
}
}
diff --git a/db/migrations/6.0.52_vips_statusgruppe_user.php b/db/migrations/6.0.52_vips_statusgruppe_user.php
new file mode 100644
index 0000000..b0c716a
--- /dev/null
+++ b/db/migrations/6.0.52_vips_statusgruppe_user.php
@@ -0,0 +1,27 @@
+<?php
+
+class VipsStatusgruppeUser extends Migration
+{
+ public function description()
+ {
+ return 'add missing entries in statusgruppe_user for vips migration';
+ }
+
+ public function up()
+ {
+ $db = DBManager::get();
+
+ // the inital migration set these to 0
+ $sql = "UPDATE etask_assignments SET end = NULL WHERE type = 'selftest' AND end = 0";
+ $db->exec($sql);
+
+ // the inital migration set these to 0
+ $sql = 'UPDATE etask_group_members SET end = NULL WHERE end = 0';
+ $db->exec($sql);
+
+ // the inital migration did not add entries to statusgruppe_user
+ $sql = 'INSERT IGNORE INTO statusgruppe_user (statusgruppe_id, user_id, mkdate)
+ SELECT group_id, user_id, start FROM etask_group_members WHERE end IS NULL';
+ $db->exec($sql);
+ }
+}