Timestamp database columns that are not created by the entity field system must be upgraded from the 4 byte integer type to the 8 byte bigint type. This is necessary to fix the Y2K38 bug.
New timestamp field columns should be created with the size is 'big'. Like:
$my_timestamp_column = [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'big',
'description' => 'My timestamp field is now fixed for the Y2K38 bug.'
];
The timestamp database columns should be updated with hook_update_N functions. Like:
function my_module_update_10101(&$sandbox = NULL) {
$connection = \Drupal::database();
if ($connection->schema()->tableExists('my_table_with_timestamp_column') && $connection->databaseType() != sqlite') {
$new = [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'big',
];
$connection->schema()->changeField('my_table_with_timestamp_column', 'my_timestamp_column', 'my_timestamp_column', $new);
}
}
The function should be spaced in your my_module.install file. If one does not exists than create one. The number 10101 is not a random number, the '101' part is for Drupal version 10.1 and the '01' part is that this is the first hook_update_N function for the given Drupal version for this module. For SQLite databases is this update not necessary as the database is already using bigint's for storing integers.