Attempt to fix db migration, making it change only entries that need it.

This hopefully cuts down the running time for the migration.