One afternoon one of the developers in the team was unable to insert records into the staging database. It raised the following error, on the primary key.
ERROR: duplicate key violates unique constraint
On top of my head, the reason this happens is because the developer inserted a row with a primary key set.
As I look at the script. The primary key field is not set in the query. It makes sense because the id field is also associated with a sequence. The user doesn’t need to define the primary when inserting it into the table.