![]() ![]() The migration script // This is how to start building a migration script. When you run the script, you will first get an overview of the changes that will happen, and then you need to confirm that you actually want to apply these changes. Then run the migration script: > contentful space migration -environment-id 'feature-1' my-migration.js We can do that with the methodīefore you run your script, remember to log in to Contentful and to select the correct space (see above for how). To be able to copy information from one entry to another, we also need to use the Contentful API directly. You can find more examples in Contentful's documentation: The migration script is in javascript, and the Contentful CLI has several useful functions built in to create migrations. > contentful space environment create -name "feature-1" -environment-id "feature-1" Log in to Contentful and select which space to use: > contenful loginĪdd a new environment called "feature-1". Install the Contentful CLI, if you don't have it already: > npm install -g contentful-cli To summarize what we are going to changeīefore we begin, create a new environmentīy working with a new Contentful environment, you don't risk anything happening to your existing data. ![]() Node Version: 15.11.0 Npm Version: output of npm -v Operating System: Windows 10 64-bit Package Version: 1.6. The 'mainImage' field is a link to an asset (an actual image file), the same asset linked from the child 'image' entry in the original content model. I have no intention of being responsible for maintaining a Contentful space on the internet forever and ever for the rest of my life, just so contentful space import can work when readers try my tutorial. Copy the Space ID and paste in the above. I want to add a new field 'mainImage', replacing 'image': Adding Contentful as Remote Schema In Contentful dashboard, click on Settings. This content model with references two levels deep just to display an image, feels too complex. The 'image' field above is a reference to another content type 'image', which looks like this: I have the following content model 'blogpost': The task: Transform the 'blogpost' content type by moving the image asset from one entry to another In this blogpost, I will show you how you can use the Contentful CLI in a migration script to copy content from one entry to another. By using migration scripts, you can add and delete fields like you can in the web app, and you can also create and insert content into existing entries. with one or more Spaces associated with your Contentful account. However, if you are planning more complex changes, migration scripts are probably the best way forward. The only step to complete at this stage is to copy the Redirect URI that is visible at. There is 1 other project in the npm registry using contentful-space-sync. Start using contentful-space-sync in your project by running npm i contentful-space-sync. This is pretty straightforward if you are doing basic changes like adding a new text field. Latest version: 4.1.3, last published: 6 years ago. In Contentful, the easiest way to change your content model is through the web app on. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |