Changing content-type ID using Migration CLI affects on reference field validations

Howdy!

We’re starting to use the Migration CLI to create and update our content types within our space. I have a question regarding how modifying a content type’s ID will affect other content type’s reference field validations which specify the aforementioned content type’s original ID. Does the validation auto-magically update as well, or is it something we need to account for in the script which changes the ID name?

For example:
Say I have a content type with an ID of linkAction. I also have a content type named post, and this content type contains a reference field with a validation that only allows referencing a linkAction.

Now say we decide to change the ID of the linkAction to linkActionBlock. How does that affect the reference field in post with the validation for what used to be called linkAction? Are those validations updated automatically when we change the ID name, or do we need to account for each content type that has a reference field with validation for linkAction to linkActionBlock within our migration script?

Thanks!

1 Like

Hey @dlorenzo,

changing a content type id is not possible in Contentful.

You could only create a new content type with the desired id and change all the references in the other content types. But as this is something completely new, it’s a manual process. Also you’d need to re-create all the entries of the old content type with the new content type, so this is nothing I would recommend in general.

What you can change, though, is the name and description properties to indicate the purpose of the content type.

Best,
Stephan

Hey @stephan.schneider,

Thanks for the feedback. I think I must have misinterpreted based on the code examples in the GitHub package repository and assumed content type IDs could change, similar to how field IDs can be changed :frowning:

Is changing content type IDs something that is planned for a future update to the Migration CLI? Our team has definitely come across instances where we named a content type one thing and then as the app grew we changed our minds on naming. It’s nice to have content type IDs match a revised name so the code can be less confusing when an ID name changes and the code can be modified to reflect the change.

Appreciate the help!

1 Like

Hey @dlorenzo,

no that’s not planned - because it’s not possible within Contentful. So this is not a limitation of the Migration CLI, but the system itself.

When something has an own url like /spaces/<your-space>/content-types/<your-ct-id> then this id is associated with the entity and currently cannot be changed.

I’m afraid you have to use a workaround or stick with the initial ids :frowning:

No worries. At least knowing it’s not something planned/possible within Contentful helps us with decisions we make when building content types in the future!

Appreciate the help and timely response to my question @stephan.schneider :raised_hands:t4:

1 Like