migrations.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. import AccountSettings from '../models/accountSettings';
  2. import Actions from '../models/actions';
  3. import Activities from '../models/activities';
  4. import Announcements from '../models/announcements';
  5. import Boards from '../models/boards';
  6. import CardComments from '../models/cardComments';
  7. import Cards from '../models/cards';
  8. import ChecklistItems from '../models/checklistItems';
  9. import Checklists from '../models/checklists';
  10. import CustomFields from '../models/customFields';
  11. import Integrations from '../models/integrations';
  12. import InvitationCodes from '../models/invitationCodes';
  13. import Lists from '../models/lists';
  14. import Rules from '../models/rules';
  15. import Settings from '../models/settings';
  16. import Swimlanes from '../models/swimlanes';
  17. import Triggers from '../models/triggers';
  18. import UnsavedEdits from '../models/unsavedEdits';
  19. import Users from '../models/users';
  20. // Anytime you change the schema of one of the collection in a non-backward
  21. // compatible way you have to write a migration in this file using the following
  22. // API:
  23. //
  24. // Migrations.add(name, migrationCallback, optionalOrder);
  25. // Note that we have extra migrations defined in `sandstorm.js` that are
  26. // exclusive to Sandstorm and shouldn’t be executed in the general case.
  27. // XXX I guess if we had ES6 modules we could
  28. // `import { isSandstorm } from sandstorm.js` and define the migration here as
  29. // well, but for now I want to avoid definied too many globals.
  30. // In the context of migration functions we don't want to validate database
  31. // mutation queries against the current (ie, latest) collection schema. Doing
  32. // that would work at the time we write the migration but would break in the
  33. // future when we'll update again the concerned collection schema.
  34. //
  35. // To prevent this bug we always have to disable the schema validation and
  36. // argument transformations. We generally use the shorthandlers defined below.
  37. const noValidate = {
  38. validate: false,
  39. filter: false,
  40. autoConvert: false,
  41. removeEmptyStrings: false,
  42. getAutoValues: false,
  43. };
  44. const noValidateMulti = { ...noValidate, multi: true };
  45. Migrations.add('board-background-color', () => {
  46. const defaultColor = '#16A085';
  47. Boards.update(
  48. {
  49. background: {
  50. $exists: false,
  51. },
  52. },
  53. {
  54. $set: {
  55. background: {
  56. type: 'color',
  57. color: defaultColor,
  58. },
  59. },
  60. },
  61. noValidateMulti,
  62. );
  63. });
  64. Migrations.add('lowercase-board-permission', () => {
  65. ['Public', 'Private'].forEach(permission => {
  66. Boards.update(
  67. { permission },
  68. { $set: { permission: permission.toLowerCase() } },
  69. noValidateMulti,
  70. );
  71. });
  72. });
  73. // Security migration: see https://github.com/wekan/wekan/issues/99
  74. Migrations.add('change-attachments-type-for-non-images', () => {
  75. const newTypeForNonImage = 'application/octet-stream';
  76. Attachments.find().forEach(file => {
  77. if (!file.isImage()) {
  78. Attachments.update(
  79. file._id,
  80. {
  81. $set: {
  82. 'original.type': newTypeForNonImage,
  83. 'copies.attachments.type': newTypeForNonImage,
  84. },
  85. },
  86. noValidate,
  87. );
  88. }
  89. });
  90. });
  91. Migrations.add('card-covers', () => {
  92. Cards.find().forEach(card => {
  93. const cover = Attachments.findOne({ cardId: card._id, cover: true });
  94. if (cover) {
  95. Cards.update(card._id, { $set: { coverId: cover._id } }, noValidate);
  96. }
  97. });
  98. Attachments.update({}, { $unset: { cover: '' } }, noValidateMulti);
  99. });
  100. Migrations.add('use-css-class-for-boards-colors', () => {
  101. const associationTable = {
  102. '#27AE60': 'nephritis',
  103. '#C0392B': 'pomegranate',
  104. '#2980B9': 'belize',
  105. '#8E44AD': 'wisteria',
  106. '#2C3E50': 'midnight',
  107. '#E67E22': 'pumpkin',
  108. '#CD5A91': 'moderatepink',
  109. '#00AECC': 'strongcyan',
  110. '#4BBF6B': 'limegreen',
  111. '#2C3E51': 'dark',
  112. '#27AE61': 'relax',
  113. '#568BA2': 'corteza',
  114. };
  115. Boards.find().forEach(board => {
  116. const oldBoardColor = board.background.color;
  117. const newBoardColor = associationTable[oldBoardColor];
  118. Boards.update(
  119. board._id,
  120. {
  121. $set: { color: newBoardColor },
  122. $unset: { background: '' },
  123. },
  124. noValidate,
  125. );
  126. });
  127. });
  128. Migrations.add('denormalize-star-number-per-board', () => {
  129. Boards.find().forEach(board => {
  130. const nStars = Users.find({ 'profile.starredBoards': board._id }).count();
  131. Boards.update(board._id, { $set: { stars: nStars } }, noValidate);
  132. });
  133. });
  134. // We want to keep a trace of former members so we can efficiently publish their
  135. // infos in the general board publication.
  136. Migrations.add('add-member-isactive-field', () => {
  137. Boards.find({}, { fields: { members: 1 } }).forEach(board => {
  138. const allUsersWithSomeActivity = _.chain(
  139. Activities.find(
  140. { boardId: board._id },
  141. { fields: { userId: 1 } },
  142. ).fetch(),
  143. )
  144. .pluck('userId')
  145. .uniq()
  146. .value();
  147. const currentUsers = _.pluck(board.members, 'userId');
  148. const formerUsers = _.difference(allUsersWithSomeActivity, currentUsers);
  149. const newMemberSet = [];
  150. board.members.forEach(member => {
  151. member.isActive = true;
  152. newMemberSet.push(member);
  153. });
  154. formerUsers.forEach(userId => {
  155. newMemberSet.push({
  156. userId,
  157. isAdmin: false,
  158. isActive: false,
  159. });
  160. });
  161. Boards.update(board._id, { $set: { members: newMemberSet } }, noValidate);
  162. });
  163. });
  164. Migrations.add('add-sort-checklists', () => {
  165. Checklists.find().forEach((checklist, index) => {
  166. if (!checklist.hasOwnProperty('sort')) {
  167. Checklists.direct.update(
  168. checklist._id,
  169. { $set: { sort: index } },
  170. noValidate,
  171. );
  172. }
  173. checklist.items.forEach((item, index) => {
  174. if (!item.hasOwnProperty('sort')) {
  175. Checklists.direct.update(
  176. { _id: checklist._id, 'items._id': item._id },
  177. { $set: { 'items.$.sort': index } },
  178. noValidate,
  179. );
  180. }
  181. });
  182. });
  183. });
  184. Migrations.add('add-swimlanes', () => {
  185. Boards.find().forEach(board => {
  186. const swimlaneId = board.getDefaultSwimline()._id;
  187. Cards.find({ boardId: board._id }).forEach(card => {
  188. if (!card.hasOwnProperty('swimlaneId')) {
  189. Cards.direct.update(
  190. { _id: card._id },
  191. { $set: { swimlaneId } },
  192. noValidate,
  193. );
  194. }
  195. });
  196. });
  197. });
  198. Migrations.add('add-views', () => {
  199. Boards.find().forEach(board => {
  200. if (!board.hasOwnProperty('view')) {
  201. Boards.direct.update(
  202. { _id: board._id },
  203. { $set: { view: 'board-view-swimlanes' } },
  204. noValidate,
  205. );
  206. }
  207. });
  208. });
  209. Migrations.add('add-checklist-items', () => {
  210. Checklists.find().forEach(checklist => {
  211. // Create new items
  212. _.sortBy(checklist.items, 'sort').forEach((item, index) => {
  213. ChecklistItems.direct.insert({
  214. title: item.title ? item.title : 'Checklist',
  215. sort: index,
  216. isFinished: item.isFinished,
  217. checklistId: checklist._id,
  218. cardId: checklist.cardId,
  219. });
  220. });
  221. // Delete old ones
  222. Checklists.direct.update(
  223. { _id: checklist._id },
  224. { $unset: { items: 1 } },
  225. noValidate,
  226. );
  227. });
  228. });
  229. Migrations.add('add-profile-view', () => {
  230. Users.find().forEach(user => {
  231. if (!user.hasOwnProperty('profile.boardView')) {
  232. // Set default view
  233. Users.direct.update(
  234. { _id: user._id },
  235. { $set: { 'profile.boardView': 'board-view-lists' } },
  236. noValidate,
  237. );
  238. }
  239. });
  240. });
  241. Migrations.add('add-card-types', () => {
  242. Cards.find().forEach(card => {
  243. Cards.direct.update(
  244. { _id: card._id },
  245. {
  246. $set: {
  247. type: 'cardType-card',
  248. linkedId: null,
  249. },
  250. },
  251. noValidate,
  252. );
  253. });
  254. });
  255. Migrations.add('add-custom-fields-to-cards', () => {
  256. Cards.update(
  257. {
  258. customFields: {
  259. $exists: false,
  260. },
  261. },
  262. {
  263. $set: {
  264. customFields: [],
  265. },
  266. },
  267. noValidateMulti,
  268. );
  269. });
  270. Migrations.add('add-requester-field', () => {
  271. Cards.update(
  272. {
  273. requestedBy: {
  274. $exists: false,
  275. },
  276. },
  277. {
  278. $set: {
  279. requestedBy: '',
  280. },
  281. },
  282. noValidateMulti,
  283. );
  284. });
  285. Migrations.add('add-assigner-field', () => {
  286. Cards.update(
  287. {
  288. assignedBy: {
  289. $exists: false,
  290. },
  291. },
  292. {
  293. $set: {
  294. assignedBy: '',
  295. },
  296. },
  297. noValidateMulti,
  298. );
  299. });
  300. Migrations.add('add-parent-field-to-cards', () => {
  301. Cards.update(
  302. {
  303. parentId: {
  304. $exists: false,
  305. },
  306. },
  307. {
  308. $set: {
  309. parentId: '',
  310. },
  311. },
  312. noValidateMulti,
  313. );
  314. });
  315. Migrations.add('add-subtasks-boards', () => {
  316. Boards.update(
  317. {
  318. subtasksDefaultBoardId: {
  319. $exists: false,
  320. },
  321. },
  322. {
  323. $set: {
  324. subtasksDefaultBoardId: null,
  325. subtasksDefaultListId: null,
  326. },
  327. },
  328. noValidateMulti,
  329. );
  330. });
  331. Migrations.add('add-subtasks-sort', () => {
  332. Boards.update(
  333. {
  334. subtaskSort: {
  335. $exists: false,
  336. },
  337. },
  338. {
  339. $set: {
  340. subtaskSort: -1,
  341. },
  342. },
  343. noValidateMulti,
  344. );
  345. });
  346. Migrations.add('add-subtasks-allowed', () => {
  347. Boards.update(
  348. {
  349. allowsSubtasks: {
  350. $exists: false,
  351. },
  352. },
  353. {
  354. $set: {
  355. allowsSubtasks: true,
  356. },
  357. },
  358. noValidateMulti,
  359. );
  360. });
  361. Migrations.add('add-subtasks-allowed', () => {
  362. Boards.update(
  363. {
  364. presentParentTask: {
  365. $exists: false,
  366. },
  367. },
  368. {
  369. $set: {
  370. presentParentTask: 'no-parent',
  371. },
  372. },
  373. noValidateMulti,
  374. );
  375. });
  376. Migrations.add('add-authenticationMethod', () => {
  377. Users.update(
  378. {
  379. authenticationMethod: {
  380. $exists: false,
  381. },
  382. },
  383. {
  384. $set: {
  385. authenticationMethod: 'password',
  386. },
  387. },
  388. noValidateMulti,
  389. );
  390. });
  391. Migrations.add('remove-tag', () => {
  392. Users.update(
  393. {},
  394. {
  395. $unset: {
  396. 'profile.tags': 1,
  397. },
  398. },
  399. noValidateMulti,
  400. );
  401. });
  402. Migrations.add('remove-customFields-references-broken', () => {
  403. Cards.update(
  404. { 'customFields.$value': null },
  405. {
  406. $pull: {
  407. customFields: { value: null },
  408. },
  409. },
  410. noValidateMulti,
  411. );
  412. });
  413. Migrations.add('add-product-name', () => {
  414. Settings.update(
  415. {
  416. productName: {
  417. $exists: false,
  418. },
  419. },
  420. {
  421. $set: {
  422. productName: '',
  423. },
  424. },
  425. noValidateMulti,
  426. );
  427. });
  428. Migrations.add('add-hide-logo', () => {
  429. Settings.update(
  430. {
  431. hideLogo: {
  432. $exists: false,
  433. },
  434. },
  435. {
  436. $set: {
  437. hideLogo: false,
  438. },
  439. },
  440. noValidateMulti,
  441. );
  442. });
  443. Migrations.add('add-displayAuthenticationMethod', () => {
  444. Settings.update(
  445. {
  446. displayAuthenticationMethod: {
  447. $exists: false,
  448. },
  449. },
  450. {
  451. $set: {
  452. displayAuthenticationMethod: true,
  453. },
  454. },
  455. noValidateMulti,
  456. );
  457. });
  458. Migrations.add('add-defaultAuthenticationMethod', () => {
  459. Settings.update(
  460. {
  461. defaultAuthenticationMethod: {
  462. $exists: false,
  463. },
  464. },
  465. {
  466. $set: {
  467. defaultAuthenticationMethod: 'password',
  468. },
  469. },
  470. noValidateMulti,
  471. );
  472. });
  473. Migrations.add('add-templates', () => {
  474. Boards.update(
  475. {
  476. type: {
  477. $exists: false,
  478. },
  479. },
  480. {
  481. $set: {
  482. type: 'board',
  483. },
  484. },
  485. noValidateMulti,
  486. );
  487. Swimlanes.update(
  488. {
  489. type: {
  490. $exists: false,
  491. },
  492. },
  493. {
  494. $set: {
  495. type: 'swimlane',
  496. },
  497. },
  498. noValidateMulti,
  499. );
  500. Lists.update(
  501. {
  502. type: {
  503. $exists: false,
  504. },
  505. swimlaneId: {
  506. $exists: false,
  507. },
  508. },
  509. {
  510. $set: {
  511. type: 'list',
  512. swimlaneId: '',
  513. },
  514. },
  515. noValidateMulti,
  516. );
  517. Users.find({
  518. 'profile.templatesBoardId': {
  519. $exists: false,
  520. },
  521. }).forEach(user => {
  522. // Create board and swimlanes
  523. Boards.insert(
  524. {
  525. title: TAPi18n.__('templates'),
  526. permission: 'private',
  527. type: 'template-container',
  528. members: [
  529. {
  530. userId: user._id,
  531. isAdmin: true,
  532. isActive: true,
  533. isNoComments: false,
  534. isCommentOnly: false,
  535. },
  536. ],
  537. },
  538. (err, boardId) => {
  539. // Insert the reference to our templates board
  540. Users.update(user._id, {
  541. $set: { 'profile.templatesBoardId': boardId },
  542. });
  543. // Insert the card templates swimlane
  544. Swimlanes.insert(
  545. {
  546. title: TAPi18n.__('card-templates-swimlane'),
  547. boardId,
  548. sort: 1,
  549. type: 'template-container',
  550. },
  551. (err, swimlaneId) => {
  552. // Insert the reference to out card templates swimlane
  553. Users.update(user._id, {
  554. $set: { 'profile.cardTemplatesSwimlaneId': swimlaneId },
  555. });
  556. },
  557. );
  558. // Insert the list templates swimlane
  559. Swimlanes.insert(
  560. {
  561. title: TAPi18n.__('list-templates-swimlane'),
  562. boardId,
  563. sort: 2,
  564. type: 'template-container',
  565. },
  566. (err, swimlaneId) => {
  567. // Insert the reference to out list templates swimlane
  568. Users.update(user._id, {
  569. $set: { 'profile.listTemplatesSwimlaneId': swimlaneId },
  570. });
  571. },
  572. );
  573. // Insert the board templates swimlane
  574. Swimlanes.insert(
  575. {
  576. title: TAPi18n.__('board-templates-swimlane'),
  577. boardId,
  578. sort: 3,
  579. type: 'template-container',
  580. },
  581. (err, swimlaneId) => {
  582. // Insert the reference to out board templates swimlane
  583. Users.update(user._id, {
  584. $set: { 'profile.boardTemplatesSwimlaneId': swimlaneId },
  585. });
  586. },
  587. );
  588. },
  589. );
  590. });
  591. });
  592. Migrations.add('fix-circular-reference_', () => {
  593. Cards.find().forEach(card => {
  594. if (card.parentId === card._id) {
  595. Cards.update(card._id, { $set: { parentId: '' } }, noValidateMulti);
  596. }
  597. });
  598. });
  599. Migrations.add('mutate-boardIds-in-customfields', () => {
  600. CustomFields.find().forEach(cf => {
  601. CustomFields.update(
  602. cf,
  603. {
  604. $set: {
  605. boardIds: [cf.boardId],
  606. },
  607. $unset: {
  608. boardId: '',
  609. },
  610. },
  611. noValidateMulti,
  612. );
  613. });
  614. });
  615. const modifiedAtTables = [
  616. AccountSettings,
  617. Actions,
  618. Activities,
  619. Announcements,
  620. Boards,
  621. CardComments,
  622. Cards,
  623. ChecklistItems,
  624. Checklists,
  625. CustomFields,
  626. Integrations,
  627. InvitationCodes,
  628. Lists,
  629. Rules,
  630. Settings,
  631. Swimlanes,
  632. Triggers,
  633. UnsavedEdits,
  634. Users,
  635. ];
  636. Migrations.add('add-missing-created-and-modified', () => {
  637. Promise.all(
  638. modifiedAtTables.map(db =>
  639. db
  640. .rawCollection()
  641. .update(
  642. { modifiedAt: { $exists: false } },
  643. { $set: { modifiedAt: new Date() } },
  644. { multi: true },
  645. )
  646. .then(() =>
  647. db
  648. .rawCollection()
  649. .update(
  650. { createdAt: { $exists: false } },
  651. { $set: { createdAt: new Date() } },
  652. { multi: true },
  653. ),
  654. ),
  655. ),
  656. )
  657. .then(() => {
  658. // eslint-disable-next-line no-console
  659. console.info('Successfully added createdAt and updatedAt to all tables');
  660. })
  661. .catch(e => {
  662. // eslint-disable-next-line no-console
  663. console.error(e);
  664. });
  665. });
  666. Migrations.add('fix-incorrect-dates', () => {
  667. const tables = [
  668. AccountSettings,
  669. Actions,
  670. Activities,
  671. Announcements,
  672. Boards,
  673. CardComments,
  674. Cards,
  675. ChecklistItems,
  676. Checklists,
  677. CustomFields,
  678. Integrations,
  679. InvitationCodes,
  680. Lists,
  681. Rules,
  682. Settings,
  683. Swimlanes,
  684. Triggers,
  685. UnsavedEdits,
  686. ];
  687. // Dates were previously created with Date.now() which is a number, not a date
  688. tables.forEach(t =>
  689. t
  690. .rawCollection()
  691. .find({ $or: [{ createdAt: { $type: 1 } }, { updatedAt: { $type: 1 } }] })
  692. .forEach(({ _id, createdAt, updatedAt }) => {
  693. t.rawCollection().update(
  694. { _id },
  695. {
  696. $set: {
  697. createdAt: new Date(createdAt),
  698. updatedAt: new Date(updatedAt),
  699. },
  700. },
  701. );
  702. }),
  703. );
  704. });
  705. Migrations.add('add-assignee', () => {
  706. Cards.update(
  707. {
  708. assignees: {
  709. $exists: false,
  710. },
  711. },
  712. {
  713. $set: {
  714. assignees: [],
  715. },
  716. },
  717. noValidateMulti,
  718. );
  719. });
  720. Migrations.add('add-profile-showDesktopDragHandles', () => {
  721. Users.update(
  722. {
  723. 'profile.showDesktopDragHandles': {
  724. $exists: false,
  725. },
  726. },
  727. {
  728. $set: {
  729. 'profile.showDesktopDragHandles': false,
  730. },
  731. },
  732. noValidateMulti,
  733. );
  734. });
  735. Migrations.add('add-profile-hiddenMinicardLabelText', () => {
  736. Users.update(
  737. {
  738. 'profile.hiddenMinicardLabelText': {
  739. $exists: false,
  740. },
  741. },
  742. {
  743. $set: {
  744. 'profile.hiddenMinicardLabelText': false,
  745. },
  746. },
  747. noValidateMulti,
  748. );
  749. });
  750. Migrations.add('add-receiveddate-allowed', () => {
  751. Boards.update(
  752. {
  753. allowsReceivedDate: {
  754. $exists: false,
  755. },
  756. },
  757. {
  758. $set: {
  759. allowsReceivedDate: true,
  760. },
  761. },
  762. noValidateMulti,
  763. );
  764. });
  765. Migrations.add('add-startdate-allowed', () => {
  766. Boards.update(
  767. {
  768. allowsStartDate: {
  769. $exists: false,
  770. },
  771. },
  772. {
  773. $set: {
  774. allowsStartDate: true,
  775. },
  776. },
  777. noValidateMulti,
  778. );
  779. });
  780. Migrations.add('add-duedate-allowed', () => {
  781. Boards.update(
  782. {
  783. allowsDueDate: {
  784. $exists: false,
  785. },
  786. },
  787. {
  788. $set: {
  789. allowsDueDate: true,
  790. },
  791. },
  792. noValidateMulti,
  793. );
  794. });
  795. Migrations.add('add-enddate-allowed', () => {
  796. Boards.update(
  797. {
  798. allowsEndDate: {
  799. $exists: false,
  800. },
  801. },
  802. {
  803. $set: {
  804. allowsEndDate: true,
  805. },
  806. },
  807. noValidateMulti,
  808. );
  809. });
  810. Migrations.add('add-members-allowed', () => {
  811. Boards.update(
  812. {
  813. allowsMembers: {
  814. $exists: false,
  815. },
  816. },
  817. {
  818. $set: {
  819. allowsMembers: true,
  820. },
  821. },
  822. noValidateMulti,
  823. );
  824. });
  825. Migrations.add('add-assignee-allowed', () => {
  826. Boards.update(
  827. {
  828. allowsAssignee: {
  829. $exists: false,
  830. },
  831. },
  832. {
  833. $set: {
  834. allowsAssignee: true,
  835. },
  836. },
  837. noValidateMulti,
  838. );
  839. });
  840. Migrations.add('add-labels-allowed', () => {
  841. Boards.update(
  842. {
  843. allowsLabels: {
  844. $exists: false,
  845. },
  846. },
  847. {
  848. $set: {
  849. allowsLabels: true,
  850. },
  851. },
  852. noValidateMulti,
  853. );
  854. });
  855. Migrations.add('add-checklists-allowed', () => {
  856. Boards.update(
  857. {
  858. allowsChecklists: {
  859. $exists: false,
  860. },
  861. },
  862. {
  863. $set: {
  864. allowsChecklists: true,
  865. },
  866. },
  867. noValidateMulti,
  868. );
  869. });
  870. Migrations.add('add-attachments-allowed', () => {
  871. Boards.update(
  872. {
  873. allowsAttachments: {
  874. $exists: false,
  875. },
  876. },
  877. {
  878. $set: {
  879. allowsAttachments: true,
  880. },
  881. },
  882. noValidateMulti,
  883. );
  884. });
  885. Migrations.add('add-comments-allowed', () => {
  886. Boards.update(
  887. {
  888. allowsComments: {
  889. $exists: false,
  890. },
  891. },
  892. {
  893. $set: {
  894. allowsComments: true,
  895. },
  896. },
  897. noValidateMulti,
  898. );
  899. });
  900. Migrations.add('add-assigned-by-allowed', () => {
  901. Boards.update(
  902. {
  903. allowsAssignedBy: {
  904. $exists: false,
  905. },
  906. },
  907. {
  908. $set: {
  909. allowsAssignedBy: true,
  910. },
  911. },
  912. noValidateMulti,
  913. );
  914. });
  915. Migrations.add('add-requested-by-allowed', () => {
  916. Boards.update(
  917. {
  918. allowsRequestedBy: {
  919. $exists: false,
  920. },
  921. },
  922. {
  923. $set: {
  924. allowsRequestedBy: true,
  925. },
  926. },
  927. noValidateMulti,
  928. );
  929. });
  930. Migrations.add('add-activities-allowed', () => {
  931. Boards.update(
  932. {
  933. allowsActivities: {
  934. $exists: false,
  935. },
  936. },
  937. {
  938. $set: {
  939. allowsActivities: true,
  940. },
  941. },
  942. noValidateMulti,
  943. );
  944. });
  945. Migrations.add('add-description-title-allowed', () => {
  946. Boards.update(
  947. {
  948. allowsDescriptionTitle: {
  949. $exists: false,
  950. },
  951. },
  952. {
  953. $set: {
  954. allowsDescriptionTitle: true,
  955. },
  956. },
  957. noValidateMulti,
  958. );
  959. });
  960. Migrations.add('add-description-text-allowed', () => {
  961. Boards.update(
  962. {
  963. allowsDescriptionText: {
  964. $exists: false,
  965. },
  966. },
  967. {
  968. $set: {
  969. allowsDescriptionText: true,
  970. },
  971. },
  972. noValidateMulti,
  973. );
  974. });