﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	parents
121	Handle migrations ourselves (NOT through mongokit)	Christopher Allan Webber	Christopher Allan Webber	"{{{
#!rst
Mongokit's migrations system stuff is complex and way confusing.
Here's something much simpler.


-  migrations are simple functions, iterated by number. You create
   them and register them with a decorator registering what ""number""
   they are like so:

   @register\_migration(1) def ponies\_to\_unicorns(database):
   database['quadrapeds'].find( {'animal': 'pony'}).update{ {'$set':
   {'animal': 'unicorn'}})


or whatever else you need to do with that connection. The first and
only argument passed in (database) is a simple pymongo database
connection (**not** mongokit!). Otherwise, it's just a simple
python function. Do what you need to do.


-  current migration status is stored in the ['\_id'] =
   'mediagoblin' document of database['app\_metadata'] in the field
   ['migration\_number']
-  if no migrations have been run yet, migration\_number set to
   current max
-  otherwise all unrun migrations are run, and migration\_number
   updated after each migration finishes.



}}}"	defect	closed	minor	0.0.4	programming	FIXED			
