change case model according to pg table