CHARP diff.sh - pupitetris/charp GitHub Wiki
A program for comparing the DDL of the running database with the declarations on the initialization SQL code. This is quite helpful for production environments where the database design changes due to bug fixing or enhancements and the database structure has to be updated. Data will not be migrated, so manual INSERT/UPDATE statement coding is still required to perform a complete migration.
diff.sh works by initializing a new database with a random name on the PostgreSQL server, dumping the schema for the new and production databases and then running [http://apgdiff.startnet.biz apgdiff] to compare them. Since apgdiff is written in Java, you will need to install a Java Runtime Environment on your system. apgdiff comes with CHARP, in the scripts/bin directory.
This script ignores all parameters.
$ ./diff.sh
The update SQL is sent to standard output, which should be redirected to a file for inspection, editing and finally execution through psql. All other processes are sent to standard error. The initialization script should run smoothly for the comparison schema creation. After the comparison is performed, the new database is dropped and all temporary files are removed.
Just as with initdb.sh, the script has to be edited and BASEDIR_VAR should be set to the name of the variable that contains the code base directory for the project.
2011-10-13: Version 9.0 of pg_dump is not working properly with Cygwin 1.7.9: it hangs. The Linux version is doing OK.
Send the process log to error.log and duplicate the resulting update SQL to the update.sql file and standard output.
$ ./diff.sh 2> error.log | tee update.sql . . <UPDATE SQL> . $