Yes, insulating foam under the door. Use 4" thick, and extend 2 feet either side of the door (inside and outside the barn - if not heated), and a little beyond the door travel (or around the posts). Put it down 6-7", and put 2-3" of your gravel or sand back over the foam. It will not heave after that.
A poured slab or concrete blocks as a threshold are only heave resistant if there is lots of well compacted clear stone with good drainage under it/them (and maybe insulation too). The insulation under the ground is more simple and low cost, and you can still grade the stone or sand above it.