Issues/Wrong table owner

The Symptoms
If you see output something like this, then it seems that in the past you have run the update-davical-database script as a database superuser, and not with "--dbuser davical_dba".

The database is version 8.4 currently at revision 1.2.7. Applying patch 1.2.8.sql ... succeeded. Successfully applied 1 patches. Supported locales updated. Updated view: dav_principal.sql applied. CalDAV functions updated. RRULE functions updated. DBD::Pg::db do failed: ERROR: permission denied for relation principal at ./update-davical-database line 400,  line 34. DBD::Pg::db do failed: ERROR: permission denied for relation sync_tokensat ./update-davical-database line 400,  line 36. DBD::Pg::db do failed: ERROR: permission denied for relation sync_changes at ./update-davical-database line 400,  line 37. DBD::Pg::db do failed: ERROR: permission denied for relation grants at ./update-davical-database line 400,  line 38. DBD::Pg::db do failed: ERROR: permission denied for relation dav_principal at ./update-davical-database line 400,  line 39. DBD::Pg::db do failed: ERROR: permission denied for sequence sync_tokens_sync_token_seq at ./update-davical-database line 400,  line 48. Database permissions updated.

Fixing the Problem
The problem can be fixed as follows:

Firstly, (as root), become the postgres user (or some other database superuser) and connect to the davical database: su - postgres psql davical \d

This will list all the tables, with an 'Owner' column which will be wrong for some tables.

Now quit psql and correct the permissions to tables with something like:

update-davical-database --nopatch --dbuser postgres --owner davical_dba

You can then stop being the database superuser, and return to where you normally run update-davical-database from, and run it again to confirm it is now able to set the table permissions for the davical_app user correctly.