Check foreign keys have same type as in main table. In my case main table has character(10) and foreign key character (5).
ERROR: operator does not exist: character varying = bytea
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 276