update sys_menu m1,sys_menu m2
set m1.ancestors=CONCAT(m2.ancestors,',',m1.parent_id)
where m1.parent_id=m2.menu_id and m1.ancestors is NULL
update sys_menu m1,sys_menu m2
set m1.ancestors=CONCAT(m2.ancestors,',',m1.parent_id)
where m1.parent_id=m2.menu_id and m1.ancestors is NULL