From 3b690046d89bb31e99a1f0b110d0c269e6c55a45 Mon Sep 17 00:00:00 2001 From: Ke Chen Date: Tue, 3 Oct 2023 09:56:38 +0800 Subject: [PATCH] feat: update course_group migrate sql --- cmd/migrate/danke_v3.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/migrate/danke_v3.go b/cmd/migrate/danke_v3.go index b0ec373..68760e4 100644 --- a/cmd/migrate/danke_v3.go +++ b/cmd/migrate/danke_v3.go @@ -239,10 +239,13 @@ where true`).Error } // update course_group.course_count, course_group.credits - err = tx.Exec(`update course_group -set course_count = (select count(*) from course where course.course_group_id = course_group.id) - credits = (select concat('[', group_concat(distinct credit), ']') from course group by course_group_id); + err = tx.Exec(`update course_group +set course_count = (select count(*) from course where course.course_group_id = course_group.id), + credits = (select concat('[', group_concat(distinct credit), ']') from course where course_group_id = course_group.id) where true`).Error + if err != nil { + return err + } if m.HasColumn(&model.Review{}, "upvoters") { err = m.DropColumn(&model.Review{}, "upvoters")