From e2ec78461a3b097cdd999ceeba3ab8aa5632bdee Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 2 Jun 2021 13:45:18 +0200 Subject: [PATCH] HOTFIX: Update production starred modules data --- db/changes/10320-monitors/02-starredModule.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/db/changes/10320-monitors/02-starredModule.sql b/db/changes/10320-monitors/02-starredModule.sql index 595d9acf0..ee00a80bd 100644 --- a/db/changes/10320-monitors/02-starredModule.sql +++ b/db/changes/10320-monitors/02-starredModule.sql @@ -1,2 +1,9 @@ ALTER TABLE `vn`.`starredModule` - ADD `position` INT NOT NULL AFTER `moduleFk`; \ No newline at end of file + ADD `position` INT NOT NULL AFTER `moduleFk`; + +SET @count:=0; +UPDATE `vn`.`starredModule` sm + JOIN ( + SELECT sm.id, IF(@workerFk = sm.workerFk, @count:=@count+1, @count:=1) AS position, @workerFk:=sm.workerFk + FROM `vn`.`starredModule` sm ORDER BY workerFk, moduleFk ASC) AS smt ON smt.id = sm.id + SET sm.position = smt.position; \ No newline at end of file