parent
093fcb9518
commit
ec3481fbcc
@ -1,8 +1,14 @@ |
||||
Meteor.startup -> |
||||
Meteor.defer -> |
||||
ChatMessage._ensureIndex({ 'expireAt': 1 }, { expireAfterSeconds: 0 }) |
||||
ChatMessage._ensureIndex({ 'rid': 1 }) |
||||
ChatMessage._ensureIndex({ 'rid': 1, 'ts': 1 }) |
||||
ChatSubscription._ensureIndex({ 'u._id': 1 }) |
||||
ChatSubscription._ensureIndex({ 'ts': 1 }) |
||||
ChatSubscription._ensureIndex({ 'rid': 1, 'u._id': 1 }, {unique: true}) |
||||
try ChatRoom._ensureIndex { 'name': 1 }, { unique: 1, sparse: 1 } catch e then console.log e |
||||
try ChatRoom._ensureIndex { 'u._id': 1 } catch e then console.log e |
||||
|
||||
try ChatSubscription._ensureIndex { 'rid': 1, 'u._id': 1 }, { unique: 1 } catch e then console.log e |
||||
try ChatSubscription._ensureIndex { 'u._id': 1, 'name': 1, 't': 1 }, { unique: 1 } catch e then console.log e |
||||
try ChatSubscription._ensureIndex { 'open': 1 } catch e then console.log e |
||||
try ChatSubscription._ensureIndex { 'alert': 1 } catch e then console.log e |
||||
try ChatSubscription._ensureIndex { 'unread': 1 } catch e then console.log e |
||||
try ChatSubscription._ensureIndex { 'ts': 1 } catch e then console.log e |
||||
|
||||
try ChatMessage._ensureIndex { 'rid': 1, 'ts': 1 } catch e then console.log e |
||||
try ChatMessage._ensureIndex { 'expireAt': 1 }, { expireAfterSeconds: 0 } catch e then console.log e |
||||
|
||||
@ -0,0 +1,28 @@ |
||||
# Meteor.startup -> |
||||
# Migrations.add |
||||
# version: 4 |
||||
# up: -> |
||||
|
||||
try ChatMessage._dropIndex 'rid_1' |
||||
try ChatSubscription._dropIndex 'u._id_1' |
||||
|
||||
|
||||
console.log 'Fixing ChatSubscription uid' |
||||
ChatSubscription.update({rn: {$exists: true}}, {$rename: {rn: 'name'}}, {multi: true}) |
||||
|
||||
ChatRoom.find({name: ''}).forEach (item) -> |
||||
name = Random.id().toLowerCase() |
||||
ChatRoom.update item._id, {$set: {name: name}} |
||||
ChatSubscription.update {rid: item._id}, {$set: {name: name}}, {multi: true} |
||||
|
||||
ChatRoom.find().forEach (room) -> |
||||
ChatRoom.find({name: room.name, _id: {$ne: room._id}}).forEach (item) -> |
||||
name = room.name + '-' + Random.id(2).toLowerCase() |
||||
ChatRoom.update item._id, {$set: {name: name}} |
||||
ChatSubscription.update {rid: item._id}, {$set: {name: name}}, {multi: true} |
||||
|
||||
ChatSubscription.find().forEach (item) -> |
||||
ChatSubscription.find({'u._id': item.u._id, name: item.name, t: item.t, _id: {$ne: item._id}}).forEach (subItem) -> |
||||
ChatSubscription.delete subItem._id |
||||
|
||||
console.log 'End' |
||||
Loading…
Reference in new issue