ca1989
Make admin user "approve" database changes
I am working on an admin website where users can perform CRUD operations on resources.
When a user with an unprivileged role changes a resource R, that should not go online immediately, but only after an admin has approved the changes.
So what I did was to create a copy of R…
Problem is R has many linked subresources S1 ... SN.
So when the unprivileged user changes R and I create a copy R1 I should copy all the subresources as well, which doesn’t feel right.
Any other approach?
I thought about maintaining the original R in the database and a separate table to keep track of the changes.
The database is Postgresql
Cheers!
Marked As Solved
mayel
One approach could be storing the user suggested changes as a single map rather than in the relational tables, and only properly inserting them there on admin approval, like this function does for e.g.: paper_trail/lib/paper_trail.ex at main · bonfire-networks/paper_trail · GitHub (and using that lib would also give you version history)








