Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of what <a href="http://code.google.com/appengine/articles/update_schema.html" rel="nofollow">the docs</a> suggest, I would suggest to use low level GAE API to migrate. </p> <p>The following code will migrate all the items of type <code>DbMyModel</code>:</p> <ul> <li><code>new_attribute</code> will be added if does not exits. </li> <li><code>old_attribute</code> will be deleted if exists. </li> <li><code>changed_attribute</code> will be converted from boolean to string (<code>True</code> to <em>Priority&nbsp;1</em>, <code>False</code> to <em>Priority&nbsp;3</em>)</li> </ul> <p>Please note that <code>query.Run</code> returns iterator returning <code>Entity</code> objects. <code>Entity</code> objects behave simply like <code>dict</code>s:</p> <pre><code>from google.appengine.api.datastore import Query, Put query = Query("DbMyModel") for item in query.Run(): if not 'new_attribute' in item: item['attribute'] = some_value if 'old_attribute' in item: del item['old_attribute'] if ['changed_attribute'] is True: item['changed_attribute'] = 'Priority 1' elif ['changed_attribute'] is False: item['changed_attribute'] = 'Priority 3' #and so on... #Put the item to the db: Put(item) </code></pre> <p>In case you need to select only some records, see the <code>google.appengine.api.datastore</code> module's source code for extensive documentation and examples how to create filtered query.</p> <p>Using this approach it is simpler to remove/add properties and avoid issues when you have already updated your application model than in GAE's suggested approach. </p> <p>For example, now-required fields might not exist (yet) causing errors while migrating. And deleting fields does not work for static properties. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload