fixed foreign keys error and postgres