thomasjohnkane / snooze

A package to simplify automating future notifications and reminders in Laravel
MIT License
867 stars 88 forks source link

How to handle code changes in Notification Classes #130

Open FredrikPAC opened 7 months ago

FredrikPAC commented 7 months ago

Hi everyone! We're stumbling on alot of issues surrounding the unserialization of older notifications which have had their code changed. We're using a postgres db, so the column is base64_encoded. How are you guys handling this scenario in your applications? To be honest im starting to feel a little sceptical about serializing the whole notification as it seems php/laravel is unable to handle quite basic changes to the serialized Notification class. And since it's encoded it's a little difficult to query and migrate the failing notifications. It feels like we might be missing a piece of the puzzle though.

Kindly Fredrik

atymic commented 7 months ago

It's been a while since we wrote the serialisation logic for this, but my understanding it works pretty much the same way as laravel jobs.

Basically just make only backward compatible changes, ie if you add a property, make it nullable, etc. The serialisation is basically the properties and their values (try to stick to basic types, or models which are re-queried from the db) and the class name.