Configuration from current directory
[gnucomo.git] / test / upgradedb
1 #!/bin/sh
2
3 #
4 #  Test the database upgrades in gcm_daemon.
5 #  Create an old, version 1, database and run gcm_daemon to perform
6 #  an upgrade to the latest version.
7 #  Then, create a latest-version database and compare dumps of these
8 #  database. They should be essentially the same.
9
10
11 createdb gnucomo_test
12
13 if psql gnucomo_test <create_v1.sql -q >/dev/null
14 then
15    cd ../src/gcm_daemon; ln -f -s ../../test/gnucomo_test.conf .; ./gcm_daemon.php -c gnucomo_test ; cd ../../test
16    pg_dump gnucomo_test |grep -v '^--' | sort >dump.upgraded.sql
17    psql gnucomo_test -f ../src/database/destroy.sql -q
18    psql gnucomo_test <../src/database/create.sql -q >/dev/null
19    pg_dump gnucomo_test |grep -v '^--' | sort >dump.latest.sql
20    psql gnucomo_test -f ../src/database/destroy.sql -q
21
22    #  Expect 28 lines of diff output (character varying vs. text types)
23    echo Comparing dump.latest.sql with dump.upgraded.sql
24    diff dump.latest.sql dump.upgraded.sql
25    result=$?
26
27    dropdb gnucomo_test
28    exit $result
29 else
30    echo Can not create test database
31    dropdb gnucomo_test
32    exit 1
33 fi