Make a schema upgrade more idempotent

Change-Id: Ic378f5f7cb18b5b9764c77cf252af1921407ead3
Merge "Make a schema upgrade more idempotent"