restructure the postgresql state