1) First you add the newfield from the model. 2) then from shell you do db(db.table).update(newfield=db.table.oldfield*100) db.commit()
3) Then you delete the oldfield from the model. On Wednesday, 16 May 2012 18:00:39 UTC-5, csantos wrote: > > Hi, > Suppose that in my db table I have a text field that stores data in an XML > format. One day, I decide to change it to a text field with the same name > but convert the data to json. In other words, I'd like to specify a > migration rule (maybe a callback?) that would convert every single entry in > my db from xml to json. Is there support for such a thing in web2py? > > Another example: My field stores double data that represents amounts of > money. Then I decide to change it to int, so the migration rule would be: > new_field = int(old_field*100.0) > return new_field > On Wednesday, 16 May 2012 18:00:39 UTC-5, csantos wrote: > > Hi, > Suppose that in my db table I have a text field that stores data in an XML > format. One day, I decide to change it to a text field with the same name > but convert the data to json. In other words, I'd like to specify a > migration rule (maybe a callback?) that would convert every single entry in > my db from xml to json. Is there support for such a thing in web2py? > > Another example: My field stores double data that represents amounts of > money. Then I decide to change it to int, so the migration rule would be: > new_field = int(old_field*100.0) > return new_field >