fix grainestablishment sql