Hi,
You must be very careful because if you change the signature of the field, you will certainly lose the old values of this field.
Luckily, when this is done, the system creates a Column where it stocks the old values.
It calls the new column : YourField_moved0;
I suggest you to test this in your LOCAL environment to be sure :
1- Change the signature of the field.
2- restart the server and upgrade your Module
3- In your Logs, you will notice the server telling you that :
Table `Your_table`: column `YourField` has changed type (DB=float8, def=char), data moved to column `YourField_moved0`
4- connect to your Database and past :
update cfdt_case set YourField=YourField_moved0;
Tip : You can start by checkin what happens before and after when you change the signature by pasting :
select YourField from YourTable;
Thanks.
So this means I have to update and after this migrate via SQL statements? Is this the standard way to go?
Yes. There is no guarantee that either Odoo or PostgreSQL can convert data from one type to another with 100% accuracy, so the safeguard that Ibrahim describes has been created to keep old data so that YOU are responsible and can make sure it is converted with 100% accuracy. This is part of the reason it is not considered a PostgreSQL best practice to change a datatype in a column. The other parts: an exclusive lock is needed on the table; a full table re-write is needed; any constraints on the column need to be re-evaluated for every row and/or may not even be applicable in the same way.
Well said Ray.