Enable automatic migrations

Ditches the previous approach as this didn't actually migrate anything.
Adds automatic migrations, including a base state to migrate from (or to
if we don't have a database).