-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #313 from rwakida/feature/12
Fix #12 Standardize collection names
- Loading branch information
Showing
4 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) | ||
|