--- /dev/null
+#!/bin/sh
+
+#
+# Test the database upgrades in gcm_daemon.
+# Create an old, version 1, database and run gcm_daemon to perform
+# an upgrade to the latest version.
+# Then, create a latest-version database and compare dumps of these
+# database. They should be essentially the same.
+
+
+createdb gnucomo_test
+
+if psql gnucomo_test <create_v1.sql -q >/dev/null
+then
+ cd ../src/gcm_daemon; ln -f -s ../../test/gnucomo_test.conf .; ./gcm_daemon.php -c gnucomo_test ; cd ../../test
+ pg_dump gnucomo_test |grep -v '^--' | sort >dump.upgraded.sql
+ psql gnucomo_test -f ../src/database/destroy.sql -q
+ psql gnucomo_test <../src/database/create.sql -q >/dev/null
+ pg_dump gnucomo_test |grep -v '^--' | sort >dump.latest.sql
+ psql gnucomo_test -f ../src/database/destroy.sql -q
+
+ # Expect 28 lines of diff output (character varying vs. text types)
+ echo Comparing dump.latest.sql with dump.upgraded.sql
+ diff dump.latest.sql dump.upgraded.sql
+ result=$?
+
+ dropdb gnucomo_test
+ exit $result
+else
+ echo Can not create test database
+ dropdb gnucomo_test
+ exit 1
+fi