Fixing a PostgreSQL Trigger That Fires Twice on UPDATE With a Row-Level Rule
Your PostgreSQL trigger logic runs twice on every UPDATE, and your audit log has duplicate rows to prove it. The culprit is almost always a row-level rule rewriting the UPDATE into two statements. Here's how to diagnose and fix it.