Hi David,
  Depends how you define easy.  You'll need to loop over the data,
convert it, then re-put it.  There are a couple ways to do this, but I
think the easiest to explain is the 'Expando two-step' method.  First,
change your kind definition to the new schema (including removing the
old properties) also switch from a db.Model to a db.Expando.  Then
loop over your entities, for each entity copy the value from the old
property to the new property, then db.put your entities.  Change your
kind back to a db.Model.

  I'd also suggest adding a 'version' property to your kind definition
to make this sort of thing easier in the future.  Personally, I stick
a "v_ = IntegerProperty(default=0)" on all of my kinds then bump the
default each time I modify the schema.  Makes finding stuff that needs
updated super easy.

  There are several choices for how you loop over your data.  The
write a handler and use task-queues, use task-queues plus deferred, or
use the map-reduce lib.  The first method is pretty easy to outline:


  def get(self):
    query = KindToMigrate.all()
    cursor = self.request.get('cursor')
    if cursor:
      query.with_cursor(cursor)

    entities = query.fetch(batch_size) # maybe a couple hundred
    if len(entities) >= batch_size:
      taskqueue.add(url=self.request.path,
                            params={'cursor': str(query.cursor())})

    for entity in entities:
      if hasattr(entity, 'old_property'):
        entity.np = entity.old_property
        delattr(entity, 'old_property')

    db.put(entities)


  I'd carefully review and test the before running it since I just
quickly typed it up. ;)


Robert




On Mon, May 30, 2011 at 17:18, David Stone <minpeng2...@gmail.com> wrote:
> Hello,
>
> Suppose i have a kind (table) called "Person" defined in GAE data
> store already, it has properties (attributes) like personId, age,
> location, phone number and contains one million tuples.  Now i just
> want to change attribute "personId" to "pId" without affect anything
> else.
>
> Is there any easy way to do so?
>
> Thanks!
>
> David
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To post to this group, send email to google-appengine@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to