Make data migration safer

As per feedback from @tekin