localwiki / localwiki-backend-server

Primary LocalWiki backend server environment
GNU General Public License v2.0
48 stars 16 forks source link

Versioning of previously unversioned model with FK doesn't work #61

Open philipn opened 9 years ago

philipn commented 9 years ago

From @mivanov on October 31, 2012 21:48

Right now versioning with FK's only works for objects created after versioning was enabled. If there are objects that were created before versioning was enabled (i.e. they have no history), when creating a historical record for a model that has the FK, their historical id will not be found , and the FK will be set to None, which may not be allowed.

Propose adding a management command or hook into syncdb to create a historical record for all versioned objects that don't have one yet (or just the ones that just started to be versioned). Either that or fixing the handling of FK's to avoid this issue.

Minor thing, but stumped me for a few.

Copied from original issue: localwiki/localwiki#369

philipn commented 9 years ago

From @mivanov on October 31, 2012 21:49

Relevant code: https://github.com/localwiki/localwiki/blob/master/sapling/versionutils/versioning/models.py#L563