Restructure the postgresql state