diff --git a/migrations/1727855666_test.ts b/migrations/1727855666_test.ts new file mode 100644 index 00000000..3c2c369c --- /dev/null +++ b/migrations/1727855666_test.ts @@ -0,0 +1,36 @@ +import { Client } from '@datocms/cli/lib/cma-client-node'; + +export default async function(client: Client): Promise { + // DatoCMS migration script + + // For more examples, head to our Content Management API docs: + // https://www.datocms.com/docs/content-management-api + + // Create an Article model: + // https://www.datocms.com/docs/content-management-api/resources/item-type/create + + const articleModel = await client.itemTypes.create({ + name: 'Article', + api_key: 'article', + }); + + // Create a Title field (required): + // https://www.datocms.com/docs/content-management-api/resources/field/create + + const titleField = await client.fields.create(articleModel, { + label: 'Title', + api_key: 'title', + field_type: 'string', + validators: { + required: {}, + }, + }); + + // Create an Article record: + // https://www.datocms.com/docs/content-management-api/resources/item/create + + const article = await client.items.create({ + item_type: articleModel, + title: 'My first article!', + }); +} \ No newline at end of file