Skip to content

Commit

Permalink
Add test migration
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerdbeentjes committed Oct 2, 2024
1 parent 0096c34 commit a10fd20
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions migrations/1727855666_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Client } from '@datocms/cli/lib/cma-client-node';

export default async function(client: Client): Promise<void> {
// 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!',
});
}

0 comments on commit a10fd20

Please sign in to comment.