Fix upgrade and install sql