Assuming a database mydb
, and a canonical database file defined in a file tables.sql
, here is a way to tell if an operational schema differs from the canonical one:
pg_dump -U postgres -a mydb > mydbdata.sql
psql -U postgres -c "drop database mydbcanonical"
psql -U postgres -c "create database mydbcanonical"
psql -U postgres -d mydbcanonical -f tables.sql
psql -U postgres -d mydbcanonical -f mydbdata.sql