Galadriel
Galadriel

Reputation: 369

Spring boot migration from 1.5.2.x to 2.3.8: How to handle LocalDateTime stored as byteArray

I had spring boot 1.5.x and now migrating to 2.3.8.RELEASE.

I have an entity with the field "private LocalDateTime endTime" and in the postgres DB it was mapped to type "bytea". Now as I have probably newer dependencies, there is the following error from flyway:

Schema-validation: wrong column type encountered in column [end_time] in table [stream_info]; found [bytea (Types#BINARY)], but expecting [timestamp (Types#TIMESTAMP)]

This appears also, when I'm starting the application with a completly new postgres DB.

Does anyone know what I have to do now? Do I need a converter? And what might be the problem here?

Upvotes: 0

Views: 171

Answers (1)

Christian Beikov
Christian Beikov

Reputation: 16400

Looks like you started with a version of Hibernate that didn't support LocalDateTime yet so it was serialized through Java serialization as bytea. Now you are using a newer Hibernate version that supports this type and properly maps it to timestamp. You only way around is to migrate the data. You will have to read in every row, deserialize the data and write it to a temporary timestamp column. After you migrated all data, you can rename the column or drop the bytea column in favor of the timestamp column. Either way, this will require manual migration effort.

Upvotes: 1

Related Questions