Migrate schema when opening database
This branch implements the logic for applying migrations to the database. The min schema version has been removed as it's redundant - if the code schema version is fully backward-compatible with an older data schema version, we can provide a no-op migration that will renumber the data schema version without changing any data.
See the migration-30-31 branch for an example of a migration.
@grote if this conflicts with your work on #1136 (closed) I apologise and take responsibility for fixing the conflicts. :-)
If we backport this to the beta branch we can also backport the denormalisation performance improvements.
Closes #594 (closed)