PG::UndefinedFunction: ERROR: function unix_timestamp(timestamp without time zone) does not exist
SELECT FLOOR((UNIX_TIMESTAMP(created_at) - 1783457675) / 3600) ..
UNIX_TIMESTAMP(created_at)
What UNIX_TIMESTAMP() Does (MySQL)
In MySQL, UNIX_TIMESTAMP() converts a DATETIME or TIMESTAMP column into a Unix timestamp (number of seconds since 1970-01-01 00:00:00 UTC).
Example in MySQL:
SQLSELECT UNIX_TIMESTAMP(created_at) FROM jobs;
-- Returns something like: 1720458000
This is very commonly used for time-based calculations and bucketing (e.g., grouping records by hour or day).
Why It Fails in PostgreSQL
PostgreSQL does not have a function called UNIX_TIMESTAMP().
When solid_queue_monitor runs this query on your production PostgreSQL database:
SQLSELECT FLOOR((UNIX_TIMESTAMP(created_at) - 1783457675) / 3600) ...
PostgreSQL throws:
PG::UndefinedFunction: ERROR: function unix_timestamp(timestamp without time zone) does not exist
Correct Equivalent in PostgreSQL
In PostgreSQL, the proper way to get a Unix timestamp is:
SQLEXTRACT(EPOCH FROM created_at)
So the equivalent of the failing query would be:
SQL-- MySQL (broken on Postgres)
FLOOR((UNIX_TIMESTAMP(created_at) - 1783457675) / 3600)
-- PostgreSQL (correct)
FLOOR((EXTRACT(EPOCH FROM created_at) - 1783457675) / 3600)
PG::UndefinedFunction: ERROR: function unix_timestamp(timestamp without time zone) does not exist
SELECT FLOOR((UNIX_TIMESTAMP(created_at) - 1783457675) / 3600) ..
UNIX_TIMESTAMP(created_at)
What UNIX_TIMESTAMP() Does (MySQL)
In MySQL, UNIX_TIMESTAMP() converts a DATETIME or TIMESTAMP column into a Unix timestamp (number of seconds since 1970-01-01 00:00:00 UTC).
Example in MySQL:
SQLSELECT UNIX_TIMESTAMP(created_at) FROM jobs;
-- Returns something like: 1720458000
This is very commonly used for time-based calculations and bucketing (e.g., grouping records by hour or day).
Why It Fails in PostgreSQL
PostgreSQL does not have a function called UNIX_TIMESTAMP().
When solid_queue_monitor runs this query on your production PostgreSQL database:
SQLSELECT FLOOR((UNIX_TIMESTAMP(created_at) - 1783457675) / 3600) ...
PostgreSQL throws:
PG::UndefinedFunction: ERROR: function unix_timestamp(timestamp without time zone) does not exist
Correct Equivalent in PostgreSQL
In PostgreSQL, the proper way to get a Unix timestamp is:
SQLEXTRACT(EPOCH FROM created_at)
So the equivalent of the failing query would be:
SQL-- MySQL (broken on Postgres)
FLOOR((UNIX_TIMESTAMP(created_at) - 1783457675) / 3600)
-- PostgreSQL (correct)
FLOOR((EXTRACT(EPOCH FROM created_at) - 1783457675) / 3600)