Invalid foreign key for field "item" in collection "directus_versions"

Hello everyone!

I am running into this error when creating a content version from the app (also happens when doing programatically) for a collection in my directus instance.

I have a bunch of relationships in this collection but just for debugging sake I deleted all fields in the collection to check if something was causing this.

I, in fact, have another collection with working versions that does not throw this error when creating a new version.

Any idea how I could solve this?

Heyo and welcome to community :waving_hand:

To me it sounds more like there could be something wrong with the collection itself, or maybe the directus_versions table instead of the fields within the collection.

  • Have you checked the collection or the directus_versions tables?
  • Have you made any changes to either of those?

Hard to think of the next best steps for you without a lot more context.

Hi Bryant! I did not make changes to the directus_versions table per se, but is as the table has directus_versions_item_foreign to be of only one collection.

I am not really an expert in sql so I don’t know what more context could be valuable but I am more than happy to send you whatever may help

Hello Bryant! I think I found where the problem is originating. In order to be able to filter my collections by those items that have a pending version I created a O2M relationship that looked at the directus_versions collection with foreign key set to Item.
Is it possible this creates a constraint for Item in directus_versions that allows only items of that collection to be set as an item?