Perform migration only if required.

This addresses issues with running both auto-upgrade and explicit
migrations.

@pbadenski
@robyoung