Fixed #22350 -- Consistently serialize bytes and text in migrations.

Thanks to treyhunner for the report and Loïc for the initial patch.