Restructure database module

* Remove unnnecessary double-namespacing
* Allow better for different database backends
* Implement a MockDatabase which is in-memory only, for testing purposes

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Remove unused methods from db class

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rework database code into a subpackage

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rework database schema checking

Instead of having our own magic table with schema information, actually
read it from sqlite itself and check that.  Allows for an easier and more
flexible way of handling database updates to new schemas.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Use the new schema conversion logic to remove the old schema table

Now that we use the magic schema detection, we don't need the schema/magic
table, so we can use the new schema update logic to remove it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Test that we correct fail updating an unknown database schema

Which in turn protects against clobbering an unrelated sqlite database.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Extend database update test

Put in some basic verification that the database update doesn't clobber
actual data in the original db.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>