# Make admin user "approve" database changes

**URL:** <https://forum.elixirforum.com/t/make-admin-user-approve-database-changes/59920>\
**Category:** Questions\
**Tags:** databases, phoenix\
**Created:** [November 23, 2023, 8:17am UTC](https://forum.elixirforum.com/t/make-admin-user-approve-database-changes/59920 "2023-11-23T08:17:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ca1989](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/c/57b2e6/32.png) [@ca1989](https://forum.elixirforum.com/u/ca1989)\
**Post date:** [November 23, 2023, 8:17am UTC](https://forum.elixirforum.com/t/make-admin-user-approve-database-changes/59920/1 "2023-11-23T08:17:07Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mayel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mayel/32/26431_2.png) [@mayel](https://forum.elixirforum.com/u/mayel)\
**Post date:** [November 23, 2023, 8:49am UTC](https://forum.elixirforum.com/t/make-admin-user-approve-database-changes/59920/2 "2023-11-23T08:49:58Z")

</div>

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](https://github.com/bonfire-networks/paper_trail/blob/main/lib/paper_trail.ex#L33) (and using that lib would also give you version history)

---

<div class="post-metadata">

**Author:** ![ca1989](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/c/57b2e6/32.png) [@ca1989](https://forum.elixirforum.com/u/ca1989)\
**Post date:** [November 23, 2023, 8:54am UTC](https://forum.elixirforum.com/t/make-admin-user-approve-database-changes/59920/3 "2023-11-23T08:54:54Z")

</div>

Nice! Thank you
