-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add discussions and messages models (#4419)
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/contentful/migrations/crn/discussions/20241016120158-create-discussions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module.exports.description = 'Create discussions content model'; | ||
|
||
module.exports.up = (migration) => { | ||
const discussions = migration | ||
.createContentType('discussions') | ||
.name('Discussions') | ||
.description(''); | ||
|
||
discussions | ||
.createField('message') | ||
.name('Message') | ||
.type('Link') | ||
.localized(false) | ||
.required(true) | ||
.disabled(false) | ||
.omitted(false) | ||
.validations([ | ||
{ | ||
linkContentType: ['messages'], | ||
}, | ||
]) | ||
.linkType('Entry'); | ||
|
||
discussions | ||
.createField('replies') | ||
.name('Replies') | ||
.type('Array') | ||
.localized(false) | ||
.required(false) | ||
.validations([]) | ||
.disabled(false) | ||
.omitted(false) | ||
.items({ | ||
type: 'Link', | ||
|
||
validations: [ | ||
{ | ||
linkContentType: ['messages'], | ||
}, | ||
], | ||
|
||
linkType: 'Entry', | ||
}); | ||
}; | ||
|
||
module.exports.down = (migration) => { | ||
migration.deleteContentType('discussions'); | ||
}; |
40 changes: 40 additions & 0 deletions
40
packages/contentful/migrations/crn/messages/20241016114412-create-messages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module.exports.description = 'Create messages content model'; | ||
|
||
module.exports.up = (migration) => { | ||
const messages = migration | ||
.createContentType('messages') | ||
.name('Messages') | ||
.description('') | ||
.displayField('text'); | ||
|
||
messages | ||
.createField('text') | ||
.name('Text') | ||
.type('Symbol') | ||
.localized(false) | ||
.required(true) | ||
.validations([]) | ||
.disabled(false) | ||
.omitted(false); | ||
|
||
messages | ||
.createField('createdBy') | ||
.name('Created By') | ||
.type('Link') | ||
.localized(false) | ||
.required(true) | ||
.disabled(false) | ||
.omitted(false) | ||
.validations([ | ||
{ | ||
linkContentType: ['users'], | ||
}, | ||
]) | ||
.linkType('Entry'); | ||
|
||
messages.changeFieldControl('text', 'builtin', 'singleLine', {}); | ||
}; | ||
|
||
module.exports.down = (migration) => { | ||
migration.deleteContentType('messages'); | ||
}; |