...
Code Block | ||
---|---|---|
| ||
const MurmurHash3 = require("imurmurhash");
module.exports = function (migration) {
migration.transformEntriesToType({
// Old content type
sourceContentType: "journey",
// New content type
targetContentType: "test",
// Field we are transferring to new type
from: ["journeyName", "journeyURLNickname"],
// We can publish the new entries by setting this to true
shouldPublish: false,
// We can point to this content type on entries referencing the old type
updateReferences: false,
removeOldEntries: false,
// This function creates a new id for the entry
identityKey: function (fields) {
const value = fields.journeyName["en-US"].toString();
return MurmurHash3(value).result().toString();
},
// This function takes the value from the old content type fields and
// transforms them to the new
transformEntryForLocale: function (fromFields, currentLocale) {
return {
automateName: `$copy - ${fromFields.journeyName[currentLocale]}`,
journeyName: `copy - ${fromFields.journeyName[currentLocale]}`,
journeyURL: `copy - ${fromFields.journeyURLNickname[currentLocale]}`,
};
},
});
}; |
...