The basic answer to your question is you can't, as BIGINT
columns can not have CURRENT_TIMESTAMP
as a default value.
If you change your column type to TIMESTAMP(3)
it will record timestamps with 3 decimal places of precision (i.e. down to milliseconds). You can have up to 6 decimal places. See the manual. In this situation you will also want to change your default to CURRENT_TIMESTAMP(3)
.
Demo on dbfiddle
A workaround to make it appear as if the column is a BIGINT
would be to create a VIEW
on the table using UNIX_TIMESTAMP
for reading e.g.
CREATE VIEW jobs_us AS
SELECT ..., UNIX_TIMESTAMP(added) AS added
FROM jobs
and use INSERT
and UPDATE
triggers to convert integer values to TIMESTAMP
format using FROM_UNIXTIME
e.g.
CREATE TRIGGER jobs_added BEFORE INSERT ON jobs
FOR EACH ROW
BEGIN
IF NEW.added IS NOT NULL THEN
SET NEW.added = FROM_UNIXTIME(NEW.added);
END IF;
END