I have a multi-environment instance of Dato where I’m attempting to write migrations to update the content models (per the docs here).
Here’s my migration script:
// DatoCMS migration script
// For more examples, head to our Content Management API docs:
// https://www.datocms.com/docs/content-management-api
//whatwedo model
const itemTypeId = '{id}';
//delete unused fields
const workDetailBlocksId = '{id}';
await client.fields.destroy(workDetailBlocksId);
console.log('deleted work detail blocks');
const servicesFieldId = '{id}';
await client.fields.destroy(servicesFieldId);
console.log('deleted service blocks');
//add field for value prop module
const field = await client.fields.create(itemTypeId, {
label: 'Services',
fieldType: 'block',
apiKey: 'services',
hint: '3-up component to display services',
localized: true,
validators: {
richTextBlocks: {
itemTypes: '{id}',
},
}
});
console.log(field);
}
Running the basic migration script dato migrate --destination=test1
, the environment is created, but when the script is run, I get the following error:
Running 1598545728_whatwedo.js...(node:4576) UnhandledPromiseRejectionWarning: ApiException: 404 NOT_FOUND (details: {"message":"Couldn't find Field with 'id'={id} [WHERE \"item_types\".\"environment_id\" = $1]"})
...
The id
values I put into the script are based off of the models in the Primary Environment. I find that if I sub in the new id
values and run the migration on the new environment it seems to work reliably.
Is this expected behavior? If it is, I guess in order to apply these to production I’d have to edit the migration script to reflect production IDs?