Correct database upgrade

This will rebuild all database tables and fill them accordingly,
it also fixes the ranks of keys and user ids.

Fingerprints are left to do.
Remove redundant Constants.DEBUG check
Adjust some scripts to install and run APG on the phone