X_DB_STATEMENT_FAILED
Means
the database refused the statement
Typical cause
any SQLSTATE the table does not classify — a syntax error, a data exception, a check or not-null violation. The server's verdict, so re-running it gives the same verdict, and the connection is not the problem. 25P03 is the exception to that reading: the server closed a transaction idle past idleInTransactionMs, and its fix is to do slow outbound work before opening the transaction
Fix
read the SQLSTATE and message in the cause; psql "$DATABASE_URL" -c "<the statement>" reproduces it by hand