Tracking changes in a table or several tables for that matter can be essential for your application, and we are going to take a look on how to do that using only the MySQL/MariaDB database. We have been tasked to log all the changes made to an orders table in an e-commerce application built with Laravel, and we need to track these events.

The better solution would be to store the user who update the order in the orders table.

15 INSERT INTO logs(table_name, column_name, primary_key, old_value, new_value, action, changed_by, created_at, updated_at)

1MariaDB [log_demo]> select * from logs; 2+----+------------+-------------+-------------+-----------+-----------+--------+---------------------+---------------------+---------------------+ 3| id | table_name | column_name | primary_key | old_value | new_value | action | changed_by | created_at | updated_at | 4+----+------------+-------------+-------------+-----------+-----------+--------+---------------------+---------------------+---------------------+
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners