converted from sqlite to postgresql