core: Track upgrade step within schema version
Track the last successful upgrade step (upgrade_###_XXX.sql) within
each schema version, storing it within 'coreinfo' table as
'schemaupgradestep'. When a schema upgrade finishes, clear
'schemaupgradestep' and set 'schemaversion'.
This allows for resuming multi-step schema upgrades that were
interrupted in the middle.
Whenever starting a schema upgrade, also check the value of
'schemaupgradestep'. One of two states exist:
1. Empty ('') or nonexistent
No interrupted schema upgrade, start the next schema version
upgrade from the first query.
2. Contains text, e.g. 'upgrade_010_alter_sender_64bit_ids'
The schema upgrade was interrupted, skip schema upgrade steps
including the specified successful step, and resume from the next
step.
For case 2, if the schema upgrade step cannot be found, warn and bail
out. This should only happen if:
1. The storage of successful query glitched, or the database was
manually changed
2. Quassel changed the filenames of upgrade queries, and the local
Quassel core version was replaced during an interrupted schema
upgrade
Modify SqliteStorage and PostgreSqlStorage to fetch/save the
'schemaupgradestep' key. Clearing this key is done atomically within
updateSchemaVersion().
(Ideally, the whole upgrade would be wrapped in a transaction, but
that doesn't seem to be easily possible.)
Modify upgradeQueries() to return a list of query strings and
resource filenames, used for tracking the upgrade step and providing
clearer feedback on what steps fail.