fix SQL constraint issue