Show Menu

Contentful Migration Cheat Sheet by

Content Type DSL

Create a new content type with given id
Set content type display name
.descr­ipt­ion('A type of animal')
Set content type descri­ption
ID of field to be used for entry title in Contentful editor
.creat­eFi­eld­('o­wner', options?)
Create a new field on the content type
.editF­iel­d('­owner', options?)
Edit the given field
Move the field up or down in Contentful editor
Delete the field from the content type
.chang­eFi­eld­Id(­'wo­ofs', 'numWo­ofs')
Change the JSON fields­[i].id

Fields DSL­eat­eFi­eld­('o­wner')
Create a field
Set display name in Contentful editor
Set field type - see below
Only when type is 'Array' - define type of items in array
Only when type is 'Link' - define type to link to
.valid­ati­ons([ { ... } ])
Set valida­tions on a field
Set field as required
Set field as having transl­ations
Set field to be not editable
Set field to not be sent over CDN
Deletes the field

Field Types

Short text max 256 chars
Long text - markdown - max 50k chars
signed integer -253 to 253
floating point number -253 to 253
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"
lat-lon pair ex. {"la­t": 52.5208, "­lon­": 13.4049}
true or false
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" } }
raw JSON
Array of any of the above, ex. [1.2, 2.9, 3.1]


linkCo­nte­ntType: ['dog']
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: [ 'image', 'video']
Types of assets which can be linked
size: { max: 999, min: 1 }
Min/Max number of objects (only for 'Array' field type)
range: { max: 999.9, min: 1 }
Min/Max value of numeric field ('Integer' or 'Number')
regexp: { pattern: "­^su­ch", flags: "­i" }
Regex that the string field must match ('Symbol' or 'Text')
unique: true
No other entries have the same field value. Ex. slug: "­/co­nta­ct-­us"
dateRange: { min: '2018-­01-­01T­00:­00:00', max: '2018-­12-­31T­23:­00:00' }
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
Custom error message for this validation


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          db Cheat Sheet
          Rails4 Model&Migration Generator (WorkInProgress) Cheat Sheet