Fixed sql upgrade