Ok, this is what worked for us. We called reset_column_information on the relevant tables before the migration. Somehow, the cached_version column is cached
in the schema cache. Also, this seems to be an issue particularly in test environment.