From 59f9b742d94b69bcfe80a72a942601f4e39397bc Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Tue, 7 May 2013 10:27:31 +0100 Subject: [PATCH] tags: add migration to set initial empty tags to an array - why was it being set to an object? --- migrations/20130507_fix_broken_tags.js | 12 ++++++++++++ migrations/new_stuff.js | 1 + 2 files changed, 13 insertions(+) create mode 100644 migrations/20130507_fix_broken_tags.js create mode 100644 migrations/new_stuff.js diff --git a/migrations/20130507_fix_broken_tags.js b/migrations/20130507_fix_broken_tags.js new file mode 100644 index 0000000000..1818442acd --- /dev/null +++ b/migrations/20130507_fix_broken_tags.js @@ -0,0 +1,12 @@ +/** + * users getting broken tags when they try to edit the first blank tag on accident + * + * mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130507_fix_broken_tags.js + */ + +db.users.find().forEach(function(user){ + if(!_.isArray(user.tags)) { + db.users.update({_id:user._id}, {$set:{tags:[]}}); + } + +}) \ No newline at end of file diff --git a/migrations/new_stuff.js b/migrations/new_stuff.js new file mode 100644 index 0000000000..fa517671a6 --- /dev/null +++ b/migrations/new_stuff.js @@ -0,0 +1 @@ +db.users.update({},{$set:{'flags.newStuff':'show'}},{multi:true}) \ No newline at end of file