Saturday, 15 June 2013

mongodb - Mongo db and java data versioning between code upgrades -



mongodb - Mongo db and java data versioning between code upgrades -

i have online service running multiple application servers couple of collections stored in mongodb. work in continuous deployment fashion, means code updates trigger automated tests followed production upgrade if goes (this complicates matters bit, question relevant non-cd deployments believe).

this works of time, 1 (or more) of core info models change, in case upgrade mess info in memory , after in db.

i'll give example:

let's have simple info object:

public class user { private string id; private string name; private string[] friendsnames; }

and decide alter user :

public class user { private string id; private string name; }

and add together friends separate collection, stores simple object such as:

public class friend { private string name; private string frienduserid; }

this leads problem. can't upgrade service before alter info construction fit new info model, , can't alter info before take downwards service, otherwise old version read new info version , messed up.

so solution bring down, run upgrade process on db alter everything, bring service new code running.

so question: wondering if there best practice solution version info (specifically mongo if relevant) older version applications able maintain working old data, , new applications "see" new data. thought of "userv1.1" , "userv1.2" class versions search appropriate class version in mongo, don't want "reinvent wheel" if thought through , came smart solution.

just clear, don't care object history, want able upgrade application versions smoothly.

welcome joy of "schemaless". in application ended coding objects such can go through "transitional" period. say, release changes model has back upwards both old , new "schema". force bits production, start long process converts over. next release, out transitional logic. pain in butt works. takes 2 releases alter schema.

java mongodb object versioning

No comments:

Post a Comment