Skip to content

Commit

Permalink
feat: update course_group migrate sql
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Oct 3, 2023
1 parent 0abe361 commit 3b69004
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/migrate/danke_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 3b69004

Please sign in to comment.