File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
apps/meteor/server/startup/migrations Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -37,5 +37,6 @@ import './v328';
3737import './v329' ;
3838import './v330' ;
3939import './v331' ;
40+ import './v332' ;
4041
4142export * from './xrun' ;
Original file line number Diff line number Diff line change 1+ import { CallHistory , Users } from '@rocket.chat/models' ;
2+
3+ import { addMigration } from '../../lib/migrations' ;
4+
5+ addMigration ( {
6+ version : 332 ,
7+ name : 'Fill contact information on older call history entries' ,
8+ async up ( ) {
9+ const cursor = CallHistory . col . aggregate ( [
10+ {
11+ $match : {
12+ external : false ,
13+ contactId : { $exists : true } ,
14+ contactName : { $exists : false } ,
15+ contactUssername : { $exists : false } ,
16+ } ,
17+ } ,
18+
19+ {
20+ $lookup : {
21+ from : Users . col . collectionName ,
22+ localField : 'contactId' ,
23+ foreignField : '_id' ,
24+ as : 'contactDetails' ,
25+ } ,
26+ } ,
27+ {
28+ $addFields : {
29+ contactName : { $first : '$contactDetails.name' } ,
30+ contactUsername : { $first : '$contactDetails.username' } ,
31+ } ,
32+ } ,
33+ {
34+ $project : {
35+ contactName : 1 ,
36+ contactUsername : 1 ,
37+ } ,
38+ } ,
39+ {
40+ $merge : {
41+ into : CallHistory . col . collectionName ,
42+ on : '_id' ,
43+ whenMatched : 'merge' ,
44+ } ,
45+ } ,
46+ ] ) ;
47+
48+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
49+ for await ( const _item of cursor ) {
50+ //
51+ }
52+ } ,
53+ } ) ;
You can’t perform that action at this time.
0 commit comments