Hello, I had successfully used Gitea for some time and a few month ago I had to transfer my gitea installation from one machine to another and also I migrated the database from MariaDB to PostgreSQL.
Everything seemed to work fine, but I have not tried to upload a new release to any of my repos.
Today I tried to do that, and in every repo I’m getting NewAttachment: pq: duplicate key value violates unique constraint "attachment_pkey"
.
Could anyone please direct in the right way to solve this problem?
I understand what the message says, but don’t really know how to solve it…
EDIT (SOLVED):
The problem was solved, here is what I did:
I traced the problem down to the attachment_id_seq
sequence.
The values from this sequence are used for attachment_pkey
primary key index on column id
from table attachment
.
For some reason that sequence was not successfully transferred during the migration, so while attachment_pkey
had values 1..25
, the last_value
in attachment_id_seq
was just 5 (it seems like initially it was one, but it gets incremented each time I tried to upload new release).
So to fix the problem I just updated the last_value
(in my case - to 26, YMMV):
ALTER SEQUENCE attachment_id_seq RESTART 26;