Rayman/fusic-meteor — pull request #49 by pepf (2014-07-03 12:22:01+00:00)
Title: Song metadata: Added date and author

Big but necessary change to database. I have also written a small snippet that allows to convert the "old style playlists" to the new type. Trying to open an old playlist results in a white screen, because the changed schema basically fails to validate ("songs" property has changed from a [String] to a [Object]).

I've tested the following snippet; it shouldn't give any problems:

```
Playlists.find({}).fetch().forEach(function(playlist) {
if(Match.test(playlist.songs,[String])) { //if playlist is "old"
console.log("old playlist");

var newSongObject =[];
playlist.songs.forEach(function(song) {
var songObject = {songId:song, added:new Date(), author:""};
newSongObject.push(songObject);
});

console.log(newSongObject);

Playlists.update({_id:playlist._id},{$set: {songs:newSongObject}});
}
});
```

It is probably best to run the code on startup on the server once, to make sure all playlists get updated, not just the ones published to the client. :wink: