Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for key-value table #378

Open
ignas2526 opened this issue Sep 1, 2020 · 0 comments
Open

Better support for key-value table #378

ignas2526 opened this issue Sep 1, 2020 · 0 comments

Comments

@ignas2526
Copy link

ignas2526 commented Sep 1, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant