docs: add note for auto-increment of primary key
See original GitHub issueWe are using the latest stable version of Hasura v.1.3.1
We have a table with a primary key of type Integer(Auto-Increment):
However, when I was writing a script to reset the database to mock data I explicitly passed the primary key IDs in the insert mutation so that the PKs and the FKs to it are always fixed. Now I see that the auto-increment of the primary key does not work and I get Uniqueness violation. duplicate key value violates unique constraint \"location_pkey\"
error when I don’t pass the id
in the mutation explicitly and even worst I cannot insert a row in the Insert Row tab.
It seems after I manually set the IDs in the insert mutation now the auto-increment mechanism got confused and doesn’t work anymore. How can I have it again for my tables?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Hey, @Veshu-Arora Thanks for your explanation. I appreciated what you said and realized the root cause of the problem. However, it’s not the solution to our problem. In our use-case, we need to manually insert id for some rows which are mock data. Also, we need that after that we can insert some new rows without id with auto-increment. We cannot simply delete those manually inserted rows to solve this issue.
After all, this is Hasura which is managing PostgreSQL for us, and when we explicitly set the ids in insert mutation it is the responsibility of Hasura to update the maximum id.
Getting this same error. I can’t insert any new rows without this error in the hasura console (and in my app if I call the graphql code). There should be a button that you can press within the hasura console to fix issues like this, to keep things in sync