T
T
tihunip2017-07-28 09:15:50
PHP
tihunip, 2017-07-28 09:15:50

How to make versioning like on a wiki?

Hello!
There is a certain base (accounting) with a bunch of fields.
You need to somehow make versioning for it like on a wiki.
That is, if the user changed 2 fields, then the history should show which ones and from which value to which one.
Tell me, is there something ready?
Thank you!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Z
Zakharov Alexander, 2017-07-28
@AlexZaharow

I did not work with accounting databases, but I use JSON for storing the history of changes for my MySQL database. There is a separate history table with fields - table_name, table_id and history (JSON) with data of the array [] type, to which JSON format records are added, which are monitored. Triggers for adding, changing, deleting hang on the user table. As soon as changes are made in the user table, the triggers write the changes to the history table. This allows you to track the entire history of work with the record from the moment of creation to deletion without inserting code into any procedures or business logic, but working abstractly only using the database tools.

S
Stanislav Makarov, 2017-07-28
@Nipheris

Math part:
- Chronological database ;
- Transaction time ;
- Temporality in SQL:2011
is a big read: one , two .

A
apro, 2017-07-28
@apro

This is how you can do it for postgresql: https://wiki.postgresql.org/wiki/Audit_trigger

M
Maxim Timofeev, 2017-07-28
@webinar

Make table history
id | article_id | old | changes
in changes write new to old old, you can write with json string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question