Better support for key-value table
ignas2526 opened this issue · 0 comments
When you have table that stores key-value pairs, it would be nice if you could store the value from the key column and not the actual column. I would also like to change the revisionable_id. Reason for this is if key-value pair row gets deleted it is impossible to trace back the value origin.
Example
For example there's the ArticleSetting model and article_settings table that has following columns: id, article_id, key, value.
Let's say we have setting "visible". It has id 123, and article_id 1. When we change its value from 0 to 1, following gets added to the revisions table:
revisionable_type: App\Repositories\Models\ArticleSetting
revisionable_id: 123
key: value
old_value: 0
new_value: 1
If row with id 123 gets deleted in article_settings, we can't know what value got changed from 0 to 1. We also don't know which article it was.
What I would like to be added to the revisions table is article_id, Article Model as revisionable_type and value from key column as a key:
revisionable_type: App\Repositories\Models\Article
revisionable_id: 1
key: visible
old_value: 0
new_value: 1
How would you do that?