Opened 14 years ago
Last modified 14 years ago
#121 closed defect (FIXED)
Handle migrations ourselves (NOT through mongokit)
| Reported by: | Christopher Allan Webber | Owned by: | Christopher Allan Webber |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.0.4 |
| Component: | programming | Keywords: | |
| Cc: | Parent Tickets: |
Description
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.
Attachments (1)
Change History (6)
comment:2 by , 14 years ago
| Status: | New → In Progress |
|---|
comment:2 by , 14 years ago
| Status: | In Progress → Closed |
|---|
This is finally done and even pushed live. If you have an old database, you might need to run a script... see the mailing list. Everything works though, yay!
comment:3 by , 14 years ago
Here's the relevant script in case you care. Run like:
::
./bin/python newmigration_fix.py
comment:4 by , 14 years ago
The original url for this bug was http://bugs.foocorp.net/issues/411 .
Relations:
#111: blocks, #86: blocks
Note:
See TracTickets
for help on using tickets.
