java - How to tailor existing MongoDB peacefully? -
supose have running mongodb instance(also using mongo sharding) millions of data , thousand of transactions per second, , have used morphia object-document mappe. since want keep project alive bug fixing, updating , ... in point changing data model inevitable. consider below example : have persisted class (model) :
private eventasset{ @id private string id; @constraints.required private string time; private eventtype eventtype; }
and have decided eventasset.class should change :
private eventasset{ @id private string id; @constraints.required private string time; @constraints.required private string assetname; }
as can see eventtype
has been removed , required assetname
added, , changes prevent application starting. major possible solutions can think of are
- create new db , insert old values , how manage switch between old , new db in way wont harm incomming few thousant transactions per second.
- use or create tool analyse class , compare against database , make necessary changes existing db , cause no harm exisitng data , incomming data flow (few thousant transaction per second)
this scenario seems every day (or @ least every few months or so) problem every live project. there accepted solution problem? suggest?
removing @constraints.required
shouldn't problem , adding new attribute fine well. app won't start because of @constraints.required
— ist annotation play framework?
i'd think requirement pretty same in relational databases — add new column, make required, , won't work longer.
possible solutions i'd see:
- drop annotation , enforce logic new writes in application
- have cleanup application adds value existing data (if that's possible). add annotation once value exists on entries.
- use multiple datastores if must — not sure if worth overhead. , use @ least morphia 1.0.0-rc0, because there has been bug before multiple datastores in single application.
Comments
Post a Comment