Some work on the model layer

Removes repetitive connection-level error handling.
Models are still responsible for handling statement-level errors.
Database migration system in place.