How to display newly created field in existing component

Hi all!

I’m facing a bug when I add another field to existing component. So, let`s say I have “youtube”-component with “video_id”-field there. And now I need to have another field there, lets say “start_time”. And I want this field to be present in every “youtube”-block across the website (~100 posts/stories).
So, I go to “Components” in Storyblok-dashboard, find “youtube”-component, add “start_time” there with default value. Now if I create another Post/Story and add “youtube”-blok there it works, I can see that “start_time” field is there (example below):

 { "_uid": "i-be265918-c581-4202-8d77-e84fdd111a00", "video_id": "hLklfFPm1js", "component": "youtube", "start_time": "0", "_editable": "<!--#storyblok#{\"name\": \"youtube\", \"space\": \"153547\", \"uid\": \"i-be265918-c581-4202-8d77-e84fdd111a00\", \"id\": \"152283916\"}-->" }

But the problem is that there`s no “start_time”-property for existing “youtube”-blocks (example below):

{ "_uid": "i-f35dc49a-0f16-4875-9861-ad4de1f57df3", "video_id": "wFjDdA91aRo", "component": "youtube", "_editable": "<!--#storyblok#{\"name\": \"youtube\", \"space\": \"153547\", \"uid\": \"i-f35dc49a-0f16-4875-9861-ad4de1f57df3\", \"id\": \"140729265\"}-->" }

I noticed if I remove “youtube”-block and add it back “start_time”-appears, but I won`t do that, since I have “youtube”-blocks in many many places across the website.

Is there any workaround to make “start_time”-appear in every “youtube”-block?

Thanks in advance!

Hello @YMarynych,

when changing the schema of a content type or component this won’t update automatically existing instances but it is possible to add new fields by manually saving them in the UI

You can also use the migration functionality of our CLI and add those fields by adding them that way. You can find more information on that here GitHub - storyblok/storyblok: You found an issue with one of our products? - submit it here as an issue! - before using migration scripts on a production space it is suggested to test it first on a copy of the space where you want to use it, just to be sure it does what you want :wink:

Best regards
Hannes

Hey @Hannes !

Thank you for helping me out! So, if I understood correctly, every time I add another field to existing content-type/component I need either to go through each Post that has component with changed schema and Save/Publish that post or run migration-script to make that automatically?

Hello @YMarynych,

yes, correct. When you add new fields to a schema those new fields won’t be added automatically so you need to save the stories of the modified types or containing modified component types, that will add those fields. The faster way is as said using a migration script.

Best regards
Hannes

1 Like