Suppose I initially create an ndb.Model and wanted to change a field's ndb property type (e.g. IntegerProperty to StringProperty), but wanted to cast the current data stored in that field so that I don't lose that data. One method would be to simply create a new field name and then migrate the data over with a script, but are there other more convenient ways of accomplishing this?
For example, suppose I had the following model:
class Car(ndb.Model):
name = ndb.StringProperty()
production_year = ndb.IntegerProperty()
And I stored an instance of the entity:
c = new Car()
c.name = "Porsche"
c.production_year = 2013
And wanted to change production_year to an ndb.StringProperty() without "losing" the value I set (it would still exist, but would not be retrievable). If I just change production_year to an instance of ndb.StringProperty(), the field value does not report a value which makes sense since the type doesn't match.
So if I changed the model to:
class Car(ndb.Model):
name = ndb.StringProperty()
production_year = ndb.StringProperty()
Attempting to retrieve the field with dot notation would result in a value of None. Anyone run into this situation, and could you explain what you did to solve it? Thanks.