从生产数据库中,我需要将一个字段从int更改为char。
当我在本地尝试时,我丢失了存储在该字段中的所有数据。
解决方案是什么?
[更改字段field_name
的类型时,Odoo将原始field
重命名为field_name_moved0
不会从数据库中删除它,如果可以访问数据库,则可以通过简单的方法轻松设置该值查询:
-- just make sure you cast the value of field_name_moved0 to varchar
update your_table_name set field_name = field_name_moved0::varchar where field_name_moved0 is not null;
注:如果再次更改字段的类型,名称将为field_name_moved1
。