added new migration and fixed pg query