diff --git a/db/changes/10480-june/00-route.sql b/db/changes/10480-june/00-route.sql new file mode 100644 index 000000000..beb7d5e41 --- /dev/null +++ b/db/changes/10480-june/00-route.sql @@ -0,0 +1,10 @@ +UPDATE `vn`.`route` r + JOIN(SELECT r.id, wl.workcenterFk + FROM `vn`.`route` r + JOIN `vn`.`routeLog` rl ON rl.originFk = r.id + JOIN `vn`.`workerLabour` wl ON wl.workerFk = rl.userFk + AND r.created BETWEEN wl.started AND IFNULL(wl.ended, r.created) + WHERE r.created BETWEEN '2021-12-01' AND CURDATE() + AND rl.action = 'insert' + )sub ON sub.id = r.id + SET r.commissionWorkCenterFk = sub.workcenterFk; \ No newline at end of file