Opened 15 years ago
Last modified 14 years ago
#64 closed defect (FIXED)
MediaEntry['uploader'] should reference User, not embed it.
| Reported by: | Christopher Allan Webber | Owned by: | |
|---|---|---|---|
| Priority: | critical | Milestone: | 0.0.2 |
| Component: | programming | Keywords: | |
| Cc: | Parent Tickets: |
Description (last modified by )
Currently we embed the User object into the MediaEntry field. Bad, bad bad! This means all sorts of terrible things, but especially that we'll be keeping potentially out of date information. We should be referencing it instead.
Change History (10)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
We could use autorefs which would use mostly the same API as we have now but would probably result in many extra queries than we would like to make.
In other words, we could do:
from pymongo.dbref import DBRef
[...]
class MediaEntry(Document):
__collection__ = 'media_entries'
structure = {
'uploader': DBRef,
Which would be faster (one less query when we don't need to reference the User) but would require an extra query whenever we pull down a MediaEntry. We could probably add def user() to make that easier.
Alternately we could turn on autorefs:
http://namlook.github.com/mongokit/dbref.html
And yeah, we'll probably migrate later. Actually doing a migration for this doesn't look hard, I just don't want to do it right now :)
comment:3 by , 15 years ago
We're pre-alpha. If something breaks, noone should cry. And it can all be easily fixed currently. IF the migration looks simple, why not try it? Major benefit: - We have an example migration in the code.- - It's tested, can be documented, etc.
if the migration is harder, it might still be an oportunity to have a "big real world example".
About auto_refs: To me, this feels a little like magic. I don't know. The mongo experts should decide.
comment:5 by , 15 years ago
[https://gitorious.org/cwebber/mediagoblin/cwebbers-mediagoblin/commits/user_migration](https://gitorious.org/cwebber/mediagoblin/cwebbers-mediagoblin/commits/user_migration)
I've made the migration here, it works. The rest of the system not updated yet to use the migration quite yet.
comment:6 by , 15 years ago
Oh by the way, to run bulk migrations you'll have to run ./bin/gmg migrate.
comment:10 by , 14 years ago
| Component: | → programming |
|---|---|
| Description: | modified (diff) |

Oh, fun, didn't expect this.
Anyway: Make sure, that the new schema has referential integrity. (We don't want to delete users that are still referenced from media, postings, etc). I hope monogo supports that.
Oh, and we'll most likely get a migration in this area later with federation, when users from remote sites post comments for example. (or are allowed to upload media...)