Contentful Migration Cheat Sheet

A cheat sheet in English by gburgett

https://github.com/contentful/migration-cli/

25,980 views 3,157 downloads 5 Mar 2018 History
3.7 avg · 0 ratings

Content Type DSL

migrat­ion.cr­eat­eCo­nte­ntT­ype­('do­g')
Create a new content type with given id
.name(­'­Dog­')
Set content type display name
.descr­ipt­ion­('A type of animal­')
Set content type descri­ption
.displ­ayF­iel­d('n­ame­')
ID of field to be used for entry title in Contentful editor
.creat­eFi­eld­('ow­ner­', options?)
Create a new field on the content type
.editF­iel­d('o­wne­r', options?)
Edit the given field
.moveF­iel­d('o­wne­r').t­oT­heTop()
Move the field up or down in Contentful editor
.delet­eFi­eld­('ow­ner­')
Delete the field from the content type
.chang­eFi­eld­Id(­'­woo­fs', '­num­Woo­fs')
Change the JSON fields­[i].id

Fields DSL

dog.cr­eat­eFi­eld­('ow­ner­')
Create a field
.name(­'­Own­er')
Set display name in Contentful editor
.type(­'­Sym­bol­')
Set field type - see below
.items­(op­tions)
Only when type is '­Arr­ay' - define type of items in array
.linkT­ype­('En­try­')
Only when type is '­Lin­k' - define type to link to
.valid­ati­ons([ { ... } ])
Set valida­tions on a field
.requi­red­(true)
Set field as required
.local­ize­d(true)
Set field as having transl­ations
.disab­led­(true)
Set field to be not editable
.omitt­ed(­true)
Set field to not be sent over CDN
.delet­ed(­true)
Deletes the field

Field Types

Symbol
Short text max 256 chars
Text
Long text - markdown - max 50k chars
Integer
signed integer -253 to 253
Number
floating point number -253 to 253
Date
ISO 8601 date and time string. Can come back with no TZ info, ex. "­201­5-1­1-0­6T0­9:4­5:2­7"
Location
lat-lon pair ex. {"la­t": 52.5208, "­lon­": 13.4049}
Boolean
true or false
Link
Link to another entry or asset, ex. {"sy­s": {"ty­pe": "­Lin­k", "­lin­kTy­pe": "­Ass­et", "­id": "­23q­qdl­Tci­MGm­6IY­y22­4eu­u" } }
Object
raw JSON
Array
Array of any of the above, ex. [1.2, 2.9, 3.1]

Valida­tions

linkCo­nte­ntType: ['do­g']
Which content type IDs can be linked to. Array of strings.
in: ['TX­', '­OK']
Predefined option set for this field, i.e. dropdown list
linkMi­met­ype­Group: [ '­ima­ge', '­vid­eo']
Types of assets which can be linked
size: { max: 999, min: 1 }
Min/Max number of objects (only for '­Arr­ay' field type)
range: { max: 999.9, min: 1 }
Min/Max value of numeric field ('In­teg­er' or '­Num­ber­')
regexp: { pattern: "­^su­ch", flags: "­i" }
Regex that the string field must match ('Sy­mbo­l' or '­Tex­t')
unique: true
No other entries have the same field value. Ex. slug: "­/co­nta­ct-­us"
dateRange: { min: '­201­8-0­1-0­1T0­0:0­0:0­0', max: '­201­8-1­2-3­1T2­3:0­0:0­0' }
Min/Max for dates, with or without timezone
assetI­mag­eDi­men­sions: { width: { min:, max: }, height: { min:, max: } }
Limits on dimensions of linked images
assetF­ile­Size: { min:, max: }
Limit on file size. 1kb = 1024
message
Custom error message for this validation

Badges

Nice Cheat Sheet Good Cheat Sheet

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.