-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow migrations to handle converting a JSON field into actual content types #142
Comments
Hey @gkulasik-livongo
|
Thanks for the help! Hm... interesting. Will this work in the Contentful CLI or just the contentful-migration library? We are trying to only use the Contentful CLI if possible in our Contentful management. Would this work if the 'Tag' content type has a uniqueness validation on the 'tag' field? Would the references automatically resolve like in deriveLinkedEntries? Also, to build on this. Let's say this works and TagSet now has a list of Tags. If TagSet was part of another content type called Article, meaning TagSet is a field on the Article content type, is it possible to then move the new TagSet.tags to Article.tags (assuming it has an equivalent field already created to consume the tags form TagSet). Thanks again - the support from the Contentful team is appreciated! |
@Khaledgarbaya I tried using the snippet you provided. I am running into an issue (I am using the Contentful CLI).
We use 'en' not 'en-US' (this is older inherited Contentful content). So I not sure where en-US is coming from. The content type is created and the field for storing the array is present (JSON from UI):
I have tried turning localization and required on and off as well. |
Hey @gkulasik-livongo, |
Yup, here is what I have:
|
Quick update here for others that may run into this problem. Depending on your use case, if you have a limited number of entries in your JSON you could take the following steps.
In terms of where this issue stands with Contentful I leave that up to @Khaledgarbaya. There may be an issue with the CLI but it was able to be somewhat worked around with multiple steps. @Khaledgarbaya any ideas on the question in #142 (comment)? |
Hi @gkulasik-livongo,
Yes, this should work with the cli although sometimes we can add more feature to the migration library itself but eventually will update the dependencies on the cli to reflect that.
Ok now I understand the issue more we should've used
Yes that make sense for advanced use cases, It would be nice if you can opne an issue as a feature request. |
Thanks @Khaledgarbaya! Any ideas on the following? This is the last issue I am struggling with:
Basically, I am trying to move this list of 'tags' up one level to eliminate an unnecessary content type for our new use case. I'm doing this work for my employer so will need some time to come up with a non-proprietary example for posting. Also, for the feature request, where do I open that? I thought this issue on Github was the feature request. Is there another location that you prefer to have the feature requests filed? |
Solve this through my procedural comments above (#142 (comment)). For the final questions, I solved those via the python content management sdk rather than using JS. |
The contentful-migration library is powerful and allows many types of flexible migrations.
One recent issue I've come across is that there is no easy way to convert a JSON field into actual content type entries. Specifically a JSON array.
Ex. I have a content type of called 'TagSet' with a JSON field called 'tags'. This JSON structure would look something like:
{ tags: [ { "tag": "github", "alternative":"github.com" }, { "tag": "bitbucket", "alternative":"bitbucket.com" } ] }
I'd like to be able to convert this into a content type 'Tag' with fields 'tag' and 'alternative'. So one TagSet could become 1+ Tags.
I think that the deriveLinkedEntries method could be a good place to start to support this. I know that there was some recent work done in #127 that solved an n to n deriveLinkedEntries migration that seems in line.
This is more of a feature request than a bug (unless there is a way to do this with the existing tools - without getting too deep into custom API work). I filed this after suggetion from Stefan on Slack.
The text was updated successfully, but these errors were encountered: