From bf68b2f2998b80d07178ef4bfdb052a24b964a86 Mon Sep 17 00:00:00 2001 From: AkosuaA Date: Fri, 18 Oct 2024 11:38:52 +0100 Subject: [PATCH] add discussions and messages models (#4419) --- .../20241016120158-create-discussions.js | 48 +++++++++++++++++++ .../20241016114412-create-messages.js | 40 ++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 packages/contentful/migrations/crn/discussions/20241016120158-create-discussions.js create mode 100644 packages/contentful/migrations/crn/messages/20241016114412-create-messages.js diff --git a/packages/contentful/migrations/crn/discussions/20241016120158-create-discussions.js b/packages/contentful/migrations/crn/discussions/20241016120158-create-discussions.js new file mode 100644 index 0000000000..51e366cb8a --- /dev/null +++ b/packages/contentful/migrations/crn/discussions/20241016120158-create-discussions.js @@ -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'); +}; diff --git a/packages/contentful/migrations/crn/messages/20241016114412-create-messages.js b/packages/contentful/migrations/crn/messages/20241016114412-create-messages.js new file mode 100644 index 0000000000..6e6996d230 --- /dev/null +++ b/packages/contentful/migrations/crn/messages/20241016114412-create-messages.js @@ -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'); +};