Open ScotterC opened 5 months ago
I think, having it as a configuration option for has_logidze
would be nice, smth like:
has_logidze aliases: {old_title_column_name: :new_title_column_name}
(Using "alias" to match the exiting alias_attribute
API)
Configuration is an interesting approach. However, column names could change many times so a key pair feels insufficient to fully deliver on that approach.
I don't think migrating the data oneself is a big deal but a readme section showcasing it. A section like "how Logidze handles table changes". This could also help clarify what kinds of logidze triggers accommodate new column changes and which ones don't. e.g. all columns excluding X seamlessly handles additional columns and renames but note the key change.
One bug to note, in the case where a Logidze user wanted the keys to be immutable, when you change column names but call it on old versions like
post.log_versions.each do |post|
post.new_title
end
the versions with only values from post.old_title
will return the latest version values for post.new_title
.
A section like "how Logidze handles table changes"
Yeah, that's a great idea for the start.
This is more an FYI for others and maybe a feature request.
When you change the column name of a logidze backed model, the history won't change the keys to reflect the new column name (I'm not sure it should). It took me a bit of time to figure out a good way to rewrite history so I thought I'd share.
One might expect history to be immutable so it may not be worth adding functionality to make the above simpler.