Fix database migration (bug 997695)