Backport bytea migration fix to v1.2

This backports f091e37dbc8982b70c7743c3190ab65c2785c9f6 to the `release-1.2` branch, it'd be great if there was a release of v1.2 that included this fix.