I am programming a Google Apps Engine Go application and I would like to change a variable name inside a structure that is stored in the datastore.
Say I have a struct:
type AA struct{
A string
BB string
}
And would like to change BB
into B
. If I try just changing BB
into B
, the datastore will start giving me errors when it would try to assign stored BB
values to new struct AA
that does not have that variable. I can add B
and still keep BB
, but then the struct would start getting messy.
How can I neatly change variable structure in GAE Go datastore without resorting to temporary copying over the entire database and wiping a lot of data?
You can have your AA
implement PropertyLoadSaver
as described in the Datastore docs, an then
Load
method copy BB
into B
Save
method just save A
and B
Take a look at the App Engine documentation about Updating Your Model's Schema tha describes the flow you need to follow in order to update your schema and then delete obsolete properties.
Hope this helps.