Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset sequence value after file-based import #6321

Closed
eliteproxy7 opened this issue Jun 16, 2021 · 8 comments · Fixed by #19328
Closed

Reset sequence value after file-based import #6321

eliteproxy7 opened this issue Jun 16, 2021 · 8 comments · Fixed by #19328

Comments

@eliteproxy7
Copy link

adding a new item on a collection, get the following error

There were validation errors for the following hidden fields:
id: Value has to be unique

Version: Directus v9.0.0-rc.76

this seemed to have started after I updated some items with the new import from file method but I am not sure.

@rijkvanzanten
Copy link
Member

this seemed to have started after I updated some items with the new import from file method but I am not sure.

Ah that would make sense actually. Those creations will save the primary keys included in the CSV, but that won't reset the sequence used in the database.

What database are you using?

@eliteproxy7
Copy link
Author

eliteproxy7 commented Jun 17, 2021 via email

@rijkvanzanten rijkvanzanten changed the title id: Value has to be unique when adding new item Reset sequence value after file-based import Jun 17, 2021
@eliteproxy7
Copy link
Author

for anyone looking how to reset this on the DB side

  1. run this query SELECT MAX(id) FROM your_table;
  2. SELECT nextval('your_table_id_seq'); mine was [your_table]_id_seq
  3. if the Valu from step 2 is not greater then the value form step1 then go to step 4
  4. run this query SELECT setval('your_table_id_seq',(SELECT GREATEST(MAX(your_id)+1,nextval('your_table_id_seq'))-1 FROM your_table)) "your_id" is the value from step 1

@rashidpathiyil

This comment was marked as resolved.

@rijkvanzanten

This comment was marked as resolved.

@rijkvanzanten
Copy link
Member

Linear: ENG-294

@florian-lefebvre
Copy link

Any ETA on this?

@rijkvanzanten
Copy link
Member

Any ETA on this?

Unfortunately, we can not provide estimates on features or fixes. As of now, the only way to get an accurate timeline or release date is to sponsor this task. We recognize that this may be an important feature/fix, but we are a small open-source organization with a lot to triage and complete. If you can't sponsor this ticket, then the next best thing is to increase its priority by giving it a 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
5 participants