Add mongodb migration scripts
parent
642e87f5ad
commit
8f543118ee
|
@ -0,0 +1,81 @@
|
|||
// categories
|
||||
var categSlugs = {};
|
||||
var topicIds = {};
|
||||
|
||||
(function(oldColl, coll) {
|
||||
print("Categs");
|
||||
var cursor = oldColl.find(), nb = 0;
|
||||
coll.drop();
|
||||
while(cursor.hasNext()) {
|
||||
var obj = cursor.next();
|
||||
categSlugs[obj._id] = obj.slug;
|
||||
coll.insert({
|
||||
_id: obj.slug,
|
||||
pos: obj.position,
|
||||
name: obj.name,
|
||||
desc: obj.description
|
||||
});
|
||||
nb ++;
|
||||
}
|
||||
coll.ensureIndex({pos: 1}, {unique: true});
|
||||
print("Done categs: " + nb);
|
||||
})(db.forum_category, db.f_categ);
|
||||
|
||||
(function(oldColl, coll) {
|
||||
print("Topics");
|
||||
var cursor = oldColl.find(), nb = 0;
|
||||
coll.drop();
|
||||
while(cursor.hasNext()) {
|
||||
var obj = cursor.next();
|
||||
var id = makeId(8);
|
||||
topicIds[obj._id] = id;
|
||||
coll.insert({
|
||||
_id: id,
|
||||
slug: obj.slug,
|
||||
categ: categSlugs[obj.category["$id"]],
|
||||
createdAt: obj.createdAt,
|
||||
updatedAt: obj.pulledAt,
|
||||
views: obj.numViews,
|
||||
name: obj.subject
|
||||
});
|
||||
nb ++;
|
||||
}
|
||||
coll.ensureIndex({categ: 1, slug: 1}, {unique: true});
|
||||
coll.ensureIndex({categ: 1});
|
||||
coll.ensureIndex({categ: 1, updatedAt: -1});
|
||||
print("Done topics: " + nb);
|
||||
})(db.forum_topic, db.f_topic);
|
||||
|
||||
(function(oldColl, coll) {
|
||||
print("Posts");
|
||||
var cursor = oldColl.find(), nb = 0;
|
||||
coll.drop();
|
||||
while(cursor.hasNext()) {
|
||||
var obj = cursor.next();
|
||||
var post = {
|
||||
_id: makeId(8),
|
||||
topic: topicIds[obj.topic["$id"]],
|
||||
createdAt: obj.createdAt,
|
||||
author: obj.authorName,
|
||||
text: obj.message
|
||||
};
|
||||
if (obj.author) {
|
||||
post.user = obj.author;
|
||||
}
|
||||
coll.insert(post);
|
||||
nb ++;
|
||||
}
|
||||
coll.ensureIndex({topic: 1});
|
||||
coll.ensureIndex({topic: 1, createdAt: -1});
|
||||
print("Done posts: " + nb);
|
||||
})(db.forum_post, db.f_post);
|
||||
|
||||
function makeId(size) {
|
||||
var text = "";
|
||||
var possible = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
for( var i=0; i < size; i++ )
|
||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
|
||||
return text;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
db.fos_user_group.drop()
|
||||
db.user.dropIndex("emailCanonical_1")
|
||||
db.user.dropIndex("isOnline_-1")
|
||||
db.user.update({},{$unset:{lastLogin: true}}, false, true)
|
||||
db.user.update({},{$unset:{isOnline: true}}, false, true)
|
||||
db.user.update({},{$unset:{gameConfigs: true}}, false, true)
|
||||
db.user.update({},{$unset:{email: true}}, false, true)
|
||||
db.user.update({},{$unset:{emailCanonical: true}}, false, true)
|
||||
db.user.update({},{$unset:{updatedAt: true}}, false, true)
|
||||
db.user.update({elo: {$lt: 800}}, {$set: {elo: 800}}, false, true)
|
11
todo
11
todo
|
@ -20,13 +20,8 @@ chess960 confirmation http://fr.lichess.org/forum/lichess-feedback/separate-960-
|
|||
use play-navigator router case class MyRegexStr(value: String); implicit val MyRegexStrPathParam: PathParam[MyRegexStr] = new PathParam[MyRegexStr] { def apply(s: MyRegexStr) = s.value}; def unapply(s: String) = val Rx = "(\w+)".r; s match { case Rx(x) => Some(x); case _ => None } }
|
||||
http://codetunes.com/2012/05/09/scala-dsl-tutorial-writing-web-framework-router
|
||||
use POST instead of GET where it makes sense
|
||||
endgame sound http://en.lichess.org/forum/lichess-feedback/checkmate-sound-feature?page=1#1
|
||||
|
||||
next deploy:
|
||||
db.user.update({},{$unset:{lastLogin: true}}, false, true)
|
||||
db.user.update({},{$unset:{isOnline: true}}, false, true)
|
||||
db.user.update({},{$unset:{gameConfigs: true}}, false, true)
|
||||
db.user.update({},{$unset:{email: true}}, false, true)
|
||||
db.user.dropIndex("emailCanonical_1")
|
||||
db.user.update({},{$unset:{emailCanonical: true}}, false, true)
|
||||
db.user.update({},{$unset:{updatedAt: true}}, false, true)
|
||||
db.user.update({elo: {$lt: 800}}, {$set: {elo: 800}}, false, true)
|
||||
mongo lichess mongo_migration_user.js
|
||||
mongo lichess mongo_migration_forum.js
|
||||
|
|
Loading…
Reference in New Issue