Fix migration to support legacy stores with deleted variants and line items

Fixes #4178