fix delete order to avoid foreign key trouble, #13971