Seaquel
PostgreSQL error code

PostgreSQL error 42P17

42P17 is the SQLSTATE PostgreSQL reports for invalid object definition, in class 42, Syntax Error or Access Rule Violation.

SQLSTATE42P17
Condition nameinvalid_object_definition
Class42 — Syntax Error or Access Rule Violation

Reproduce it, then fix it

An index stores values once, so everything in it has to be IMMUTABLE, and now() changes all the time. Index the column itself; a range query like created_at > now() - interval '30 days' still uses it. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.

CREATE INDEX ON orders ((now() - created_at));
CREATE INDEX ON orders (created_at);

Source: PostgreSQL documentation, Appendix A