It is a good practice to track when the data was inserted into a database or modified. However, relying on the backend applications to set that information correctly is error-prone. That’s why we can configure a MySQL table to automatically use the current timestamp as the default value and store that time as the row creation time.

Table of Contents

  1. Get Weekly AI Implementation Insights

We have to do that when the table is created (or alter an existing table):

create table table_name (
    ...
    created_ts   timestamp default current_timestamp
);

Similarly, we can track the table update time. In this case, we have to use the on update clause:

updated_ts   timestamp default current_timestamp on update current_timestamp

Get Weekly AI Implementation Insights

Join engineering leaders who receive my analysis of common AI production failures and how to prevent them. No fluff, just actionable techniques.

Get Weekly AI Implementation Insights

Join engineering leaders who receive my analysis of common AI production failures and how to prevent them. No fluff, just actionable techniques.

Older post

Best practices about partitioning data in S3 by date

How to partition data in S3 by date in a way that makes your life easier

Newer post

Get an XCom value in the Airflow on_failure_callback function

How to get the task instance in the on_failure_callback to get access to XCom

Engineering leaders: Is your AI failing in production? Take the 10-minute assessment
>