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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners