-
Notifications
You must be signed in to change notification settings - Fork 83
Description
So I have an interesting issue. I've added an integer column featured_photo that's null by default to a model that has logidze. And when I set the column for the first time, logidze enters it as expected:
{
"c"=>{"updated_at"=>"2023-03-10 15:38:37.605265", "featured_photo"=>39186},
"m"=>{"_r"=>2},
"v"=>9,
"ts"=>1678462717605
}
But when I want to check the value at any version, it always returns the current version one even when it was nil in previous versions:
irb(main):027:0> cafe.at(version: 8).featured_photo
=> 39186
irb(main):028:0> cafe.at(version: 9).featured_photo
=> 39186
irb(main):029:0> cafe.at(version: 1).featured_photo
=> 39186
I looked through the source code and the hammer fix is to add
object_at.restore_attributes(object_at.attribute_names - ["log_data"])
on line 251 here before we start restoring attributes.
But I'm not sure if that'll have some other non-desired consequences.
Ideally on new column creation I would be able to add new version to all models with that column being nil or whatever the default value is. But that's not there, so to go back to the issue title: what would be a "correct" way of letting logidze know about a new column?