Closed renou closed 7 years ago
It uses the last snapshot when getting an entity, I think. So if you just make another snapshot it should be used. However, when creating the snapshot it might try to use the last one if there haven't been any subsequent events, and anyway it might try to use the old snapshot to get the latest entity state. So you might just need to craft yourself a new function to create new snapshots that doesn't at all use the old snapshots, then the old ones should be ignored. Perhaps that should be an option of the take_snapshot() function.
Please note, if you're using the 'until' option when getting a snapshot, so you see what was effective at a particular time, you will have to decide whether the old projection or the new is required. If you need to see what was effective at a time before the new snapshots are made, but you want the new projection to apply, then you'll have to write some code to update the old snapshot events.
Good luck! Let me know how you get on?
yep yep, I agree, maybe a removal of snapshot rows in the database level is enough too in the case of rebuilding snapshots. Let me think more...
Yes you could just remove them from the database. In case you were looking, there's zero code in the eventsourcing library to update or delete stored events. Maybe there should be.
Yep, my initial idea was to store snapshots in a separate table so that we can clean it up without deleting anything from the event table. Since event table should be append only, I would remove any all user's delete and update privilege of the event table.
Good plan 👍 .
Oh, btw, we open sourced our django eventsourcing library. It has a django adaptor to this eventsourcing library. Just the schema is a bit different. :)
How marvellous. Thanks for lettings me know. I'll check it out!
Hi John! Is there any ability to discard old snaphots and rebuild new ones? In the case of the change of mutator function, the old snapshot will become invalid and needs to be discarded and rebuilt.