Search code examples
content-management-systemdirectus

Can't Create Item When Table Has Data


I have a problem where if my table is empty, I can create new items with Directus. But, if the table has data already I get the error ID: Value has to be unique. I'm using auto increment for my ID's. Any ideas what I've done wrong?


Solution

  • I had similar issue after importing data from another directus and database. I was able to resolve this issue by going into postgres database using psql and resetting auto increment with SELECT setval('my_table_id_seq', (SELECT max(id) FROM my_table)); and then inserting one row INSERT INTO my_table(column1, column2, ...) VALUES (value1, value2, ...); after that I was able to create new table rows thru directs.