Trigger function error: Record "old" not yet assigned
In the case of an INSERT, there is no previous version of the row, so the OLD variable is unassigned.

See the documentation:


  OLD
  
  &#x2003;&#x2003;&#x2003;Data type RECORD; variable holding the old database row for UPDATE/DELETE operations in row-level triggers. This variable is null in statement-level triggers and for INSERT operations.