Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/lib/collections.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@UserAndRoom = new Meteor.Collection null
@ChatMessageHistory = new Meteor.Collection null

@ChatRoom = new Meteor.Collection 'data.ChatRoom'
@ChatSubscription = new Meteor.Collection 'data.ChatSubscription'
# @ChatMessage = new Meteor.Collection 'data.ChatMessage'
@ChatRoom = new Meteor.Collection 'rocketchat_room'
@ChatSubscription = new Meteor.Collection 'rocketchat_subscription'
#@ChatMessage = new Meteor.Collection 'rocketchat_message'

# Meteor.startup ->
# ChatMessage.find().observe
Expand Down
6 changes: 3 additions & 3 deletions server/lib/collections.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@ChatMessage = new Meteor.Collection 'data.ChatMessage'
@ChatRoom = new Meteor.Collection 'data.ChatRoom'
@ChatSubscription = new Meteor.Collection 'data.ChatSubscription'
@ChatMessage = new Meteor.Collection 'rocketchat_message'
@ChatRoom = new Meteor.Collection 'rocketchat_room'
@ChatSubscription = new Meteor.Collection 'rocketchat_subscription'
8 changes: 4 additions & 4 deletions server/publications/messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Meteor.publish 'messages', (rid, start) ->

cursorHandle = cursor.observeChanges
added: (_id, record) ->
publication.added('data.ChatMessage', _id, record)
publication.added('rocketchat_message', _id, record)

changed: (_id, record) ->
publication.changed('data.ChatMessage', _id, record)
publication.changed('rocketchat_message', _id, record)

cursorDelete = ChatMessage.find
rid: rid
Expand All @@ -37,9 +37,9 @@ Meteor.publish 'messages', (rid, start) ->

cursorDeleteHandle = cursorDelete.observeChanges
added: (_id, record) ->
publication.added('data.ChatMessage', _id, {_deleted: true})
publication.added('rocketchat_message', _id, {_deleted: true})
changed: (_id, record) ->
publication.added('data.ChatMessage', _id, {_deleted: true})
publication.added('rocketchat_message', _id, {_deleted: true})

@ready()
@onStop ->
Expand Down
37 changes: 37 additions & 0 deletions server/startup/migrations/v9.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Meteor.startup ->
Migrations.add
version: 9
up: ->
# Migrate existing source collection data to target collection
# target collection is defined in collections.coffee using the new collection name
toMigrate = [
{
source: new Meteor.Collection 'data.ChatRoom'
target: ChatRoom
}
{
source: new Meteor.Collection 'data.ChatSubscription'
target: ChatSubscription
}
{
source: new Meteor.Collection 'data.ChatMessage'
target: ChatMessage
}
]

toMigrate.forEach ( collection ) ->
source = collection.source
target = collection.target
# rawCollection available as of Meteor 1.0.4
console.log 'Migrating data from: ' + source.rawCollection().collectionName + ' to: ' + target.rawCollection().collectionName
source.find().forEach ( doc ) ->
target.upsert({_id: doc._id}, doc )

rawSource = source.rawCollection();
Meteor.wrapAsync(rawSource.drop, rawSource )()

# Note: the following would have been much easier, but didn't work. The serverside
# data was not published to the client for some reason.
# newName = target.rawCollection().collectionName
# Meteor.wrapAsync(rawSource.rename, rawSource )(newName, {dropTarget:true})