summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2019-02-24 12:55:34 +0100
committerAndrés Manelli <andresmanelli@gmail.com>2019-02-24 12:55:34 +0100
commit7033315cd36530330af6f785716cce9342ef4a72 (patch)
tree41d3c35470e598f6b060db320a7e1a7365b4d0fe
parent775476f97c1dda92e856ca4650e6003ea1487d2b (diff)
downloadwekan-7033315cd36530330af6f785716cce9342ef4a72.tar.gz
wekan-7033315cd36530330af6f785716cce9342ef4a72.tar.bz2
wekan-7033315cd36530330af6f785716cce9342ef4a72.zip
Add migrations
-rw-r--r--server/migrations.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/server/migrations.js b/server/migrations.js
index 8dcd892a..cb64b7e8 100644
--- a/server/migrations.js
+++ b/server/migrations.js
@@ -422,3 +422,98 @@ Migrations.add('add-defaultAuthenticationMethod', () => {
},
}, noValidateMulti);
});
+
+Migrations.add('add-templates', () => {
+ Boards.update({
+ type: {
+ $exists: false,
+ },
+ }, {
+ $set: {
+ type: 'board',
+ },
+ }, noValidateMulti);
+ Swimlanes.update({
+ type: {
+ $exists: false,
+ },
+ }, {
+ $set: {
+ type: 'swimlane',
+ },
+ }, noValidateMulti);
+ Lists.update({
+ type: {
+ $exists: false,
+ },
+ swimlaneId: {
+ $exists: false,
+ },
+ }, {
+ $set: {
+ type: 'list',
+ swimlaneId: '',
+ },
+ }, noValidateMulti);
+ Users.find({
+ 'profile.templatesBoardId': {
+ $exists: false,
+ },
+ }).forEach((user) => {
+ // Create board and swimlanes
+ Boards.insert({
+ title: TAPi18n.__('templates'),
+ permission: 'private',
+ type: 'template-container',
+ members: [
+ {
+ userId: user._id,
+ isAdmin: true,
+ isActive: true,
+ isNoComments: false,
+ isCommentOnly: false,
+ },
+ ],
+ }, (err, boardId) => {
+
+ // Insert the reference to our templates board
+ Users.update(user._id, {$set: {'profile.templatesBoardId': boardId}});
+
+ // Insert the card templates swimlane
+ Swimlanes.insert({
+ title: TAPi18n.__('card-templates-swimlane'),
+ boardId,
+ sort: 1,
+ type: 'template-container',
+ }, (err, swimlaneId) => {
+
+ // Insert the reference to out card templates swimlane
+ Users.update(user._id, {$set: {'profile.cardTemplatesSwimlaneId': swimlaneId}});
+ });
+
+ // Insert the list templates swimlane
+ Swimlanes.insert({
+ title: TAPi18n.__('list-templates-swimlane'),
+ boardId,
+ sort: 2,
+ type: 'template-container',
+ }, (err, swimlaneId) => {
+
+ // Insert the reference to out list templates swimlane
+ Users.update(user._id, {$set: {'profile.listTemplatesSwimlaneId': swimlaneId}});
+ });
+
+ // Insert the board templates swimlane
+ Swimlanes.insert({
+ title: TAPi18n.__('board-templates-swimlane'),
+ boardId,
+ sort: 3,
+ type: 'template-container',
+ }, (err, swimlaneId) => {
+
+ // Insert the reference to out board templates swimlane
+ Users.update(user._id, {$set: {'profile.boardTemplatesSwimlaneId': swimlaneId}});
+ });
+ });
+ });
+});