Skip to content

Instantly share code, notes, and snippets.

@swider
Created December 6, 2011 19:15
Show Gist options
  • Save swider/1439510 to your computer and use it in GitHub Desktop.
Save swider/1439510 to your computer and use it in GitHub Desktop.
Script to update theme slugs
/********************************************************************
* fix-theme-slugs-mongo.js
*
* To run, replace localhost/db_name with your connection info and
* run this command:
*
* mongo localhost/db_name --quiet fix-layout-slugs-mongo.js
*
*/
var newSlugs = new Array();
newSlugs["bonapetit"] = "menu";
newSlugs["creativejuice"] = "vibrant_abstract";
newSlugs["darkroom"] = "dark_chrome";
newSlugs["ecoenviro"] = "eco";
newSlugs["fashionmi"] = "fashion";
newSlugs["kids_toys"] = "playtime";
newSlugs["lifestyle2"] = "magazine";
newSlugs["maliku_blue"] = "cool_rays";
newSlugs["medica"] = "corporate";
newSlugs["papermade"] = "crafty";
newSlugs["rayoflight"] = "faith";
newSlugs["refolio"] = "fabrica_noir";
newSlugs["shortandsimple"] = "concise";
newSlugs["welcome_inn"] = "classy";
newSlugs["outdoors"] = "sunny";
print("===== Themes =====");
db.themes.find().forEach( function(theme) {
print(theme.name);
if(newSlugs[theme.slug]){
theme.slug = newSlugs[theme.slug];
print("\tNew Slug: " + theme.slug);
}else{
print("\tUnchaged");
}
db.themes.save(theme);
});
print("===== Sites =====");
db.sites.find().forEach( function(site) {
print(site.username);
if(newSlugs[site.theme]){
site.theme = newSlugs[site.theme];
print("\tNew Slug: " + site.theme);
}else{
print("\tUnchaged");
}
db.sites.save(site);
});
print("===== Published Sites =====");
db.publishedSites.find().forEach( function(site) {
print(site.siteId);
if(newSlugs[site.theme]){
site.theme = newSlugs[site.theme];
print("\tNew Slug: " + site.theme);
}else{
print("\tUnchaged");
}
db.sites.save(site);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment