# Invalid foreign key for field "item" in collection "directus\_versions"

**URL:** https://community.directus.com/t/invalid-foreign-key-for-field-item-in-collection-directus-versions/556
**Category:** Help
**Tags:** versioning
**Created:** [June 13, 2025, 8:15am UTC](https://community.directus.com/t/invalid-foreign-key-for-field-item-in-collection-directus-versions/556 "2025-06-13T08:15:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![cristobalbahe](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@cristobalbahe](https://community.directus.com/u/cristobalbahe)
#### Post date: [June 13, 2025, 8:15am UTC](https://community.directus.com/t/invalid-foreign-key-for-field-item-in-collection-directus-versions/556/1 "2025-06-13T08:15:28Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![bryantgillespie](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/bryantgillespie/32/33_2.png) [@bryantgillespie](https://community.directus.com/u/bryantgillespie)
#### Post date: [June 13, 2025, 12:50pm UTC](https://community.directus.com/t/invalid-foreign-key-for-field-item-in-collection-directus-versions/556/2 "2025-06-13T12:50:43Z")

</div>

Heyo and welcome to community 👋

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.

---

<div class="post-metadata">

### Author: ![cristobalbahe](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@cristobalbahe](https://community.directus.com/u/cristobalbahe)
#### Post date: [July 1, 2025, 9:06am UTC](https://community.directus.com/t/invalid-foreign-key-for-field-item-in-collection-directus-versions/556/3 "2025-07-01T09:06:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cristobalbahe](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@cristobalbahe](https://community.directus.com/u/cristobalbahe)
#### Post date: [July 2, 2025, 7:35am UTC](https://community.directus.com/t/invalid-foreign-key-for-field-item-in-collection-directus-versions/556/4 "2025-07-02T07:35:58Z")

</div>

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?
