Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Handling Changes in Model Definition
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
pmargani  
View profile  
 More options Feb 11 2011, 6:17 am
From: pmargani <pmarg...@nrao.edu>
Date: Fri, 11 Feb 2011 03:17:57 -0800 (PST)
Local: Fri, Feb 11 2011 6:17 am
Subject: Handling Changes in Model Definition
Hi,
I've been using Reversion successfully for about a year, but recently
hit a snag.  The definition of one of my Models has changed (a field
was removed), and now viewing the history does not work as before;
more specifically, deserializing the versions of this Model throws a
FieldDoesNotExist error.
So, is there support for handling changes to the Model definition in
Reversion?
Thanks
Paul

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Hall  
View profile  
 More options Feb 11 2011, 7:14 am
From: David Hall <da...@etianen.com>
Date: Fri, 11 Feb 2011 12:14:25 +0000
Local: Fri, Feb 11 2011 7:14 am
Subject: Re: Handling Changes in Model Definition

Hi,

I get this question a lot! :P

The short, sad answer, is that Reversion relies on Django's model
serialization framework, which doesn't allow models with missing fields to
be deserialized. Until they add this feature, my hands are tied. (Well, I
could write my own model serializer, but I don't really fancy that!).

If a model definition changes so that a new field is added, it should all
just work. If a model definition changes so a field is removed, no dice.

I typically only use Reversion in it's admin capacity myself, so my approach
has always been to let the website admin know, then selectively delete the
Version models that will no longer deserialize.

It sucks, but this is a general feature of schema migrations. If you feel
strongly about this issue, go poke the Django dev team to allow models to be
deserialized in a way that ignores FieldDoesNotExist errors!

Anyway, sorry not to be any more help. I'm glad that Reversion has otherwise
performed well for you!

Best,

Dave.

On 11 February 2011 11:17, pmargani <pmarg...@nrao.edu> wrote:

--
Dave Hall
Etianen.com

Telephone: 07525 452381
Web: http://www.etianen.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pmargani  
View profile   Translate to Translated (View Original)
 More options Feb 11 2011, 7:52 am
From: pmargani <pmarg...@nrao.edu>
Date: Fri, 11 Feb 2011 04:52:40 -0800 (PST)
Local: Fri, Feb 11 2011 7:52 am
Subject: Re: Handling Changes in Model Definition
Thanks a lot Dave!
That was the unwanted answer that I was expecting.  Indeed, Reversion
has worked fine with additional fields, but doesn't like it when
fields are taken away.
Since I'm up the creek anyways, I was thinking of hacking the
Reversion tables in my database to remove the fields that no longer
exist.  I suppose that would involve parsing the 'serialized_data'
text in the 'reversion_version' table, removing the field that no
longer exists, and (carefully) writing back.  Apart from being a
horrible hack, do you see any problems with that?
Thanks again for this great package.
Paul

On Feb 11, 7:14 am, David Hall <da...@etianen.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Hall  
View profile  
 More options Feb 11 2011, 7:54 am
From: David Hall <da...@etianen.com>
Date: Fri, 11 Feb 2011 12:54:30 +0000
Local: Fri, Feb 11 2011 7:54 am
Subject: Re: Handling Changes in Model Definition

Hi Paul,

Nope, that sounds like a reasonable suggestion! Assuming you're using the
JSON serialization format, it should be pretty easy to accomplish too. Not
even sure if it qualifies as a hack. It's just modifying data, after all.
Thats what programmers DO! :P

Good luck!

Dave.

On 11 February 2011 12:52, pmargani <pmarg...@nrao.edu> wrote:

--
Dave Hall
Etianen.com

Telephone: 07525 452381
Web: http://www.etianen.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Baker  
View profile  
 More options Feb 11 2011, 9:07 am
From: Andy Baker <a...@andybak.net>
Date: Fri, 11 Feb 2011 14:07:28 +0000
Local: Fri, Feb 11 2011 9:07 am
Subject: Re: Handling Changes in Model Definition
If django-reversion added a few utility functions for modifying
serialized data then it wouldn't be too hard to integrate with South
et al.

I'm thinking some functions to handle common cases like removing or
renaming a field.

Andy.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Hall  
View profile  
 More options Feb 11 2011, 11:46 am
From: David Hall <da...@etianen.com>
Date: Fri, 11 Feb 2011 16:46:27 +0000
Local: Fri, Feb 11 2011 11:46 am
Subject: Re: Handling Changes in Model Definition

Some commands to migrate version data might be a good idea. I guess the
question is whether they would cover enough common use-cases to be worth
including, and trying to make the syntax non-obscure.

Something like:

django-admin.py reversion_modify app_label model_name field_name
[rename/remove] [new_name]

It's a bit long, though.

On 11 February 2011 14:07, Andy Baker <a...@andybak.net> wrote:

--
Dave Hall
Etianen.com

Telephone: 07525 452381
Web: http://www.etianen.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Baker  
View profile  
 More options Feb 12 2011, 9:12 am
From: Andy Baker <a...@andybak.net>
Date: Sat, 12 Feb 2011 14:12:04 +0000
Local: Sat, Feb 12 2011 9:12 am
Subject: Re: Handling Changes in Model Definition
On Fri, Feb 11, 2011 at 4:46 PM, David Hall <da...@etianen.com> wrote:

<snip>

>django-admin.py reversion_modify app_label model_name field_name
> [rename/remove] [new_name]
> It's a bit long, though.

1. In most cases you'd be running it in Python rather than via
manage.py as you'd probably be using something like South
2. You could have two commands rather than one dual-purpose one

So it might be more like:

  from reversion.migrate import rename_field
  rename_field('app', 'old_name', new_name)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »