However, one caveat of this type of scalable data structure is introduced when you try to update a field within a content type. Let me digress by saying if you have yet to enter any data for your content type, then you can skip this article all together, but something tells me if you are reading this, then you have experienced the caveat i mentioned, being you can not change a fields storage type once data has been inserted.
Fair enough, i can see how this would break things and even lose data, switching a fields storage type at will, but if it has to be done we will have to leave the comfort of Drupal’s gui to achieve it! If you have never opened up the data storage hood of Drupal and you have created quite a few content types, you will be taken back at first at the amount of tables involved in achieving the this type of data storage. This is because each field within a content type requires its own table to store what content bundle it belongs to and of course all the data inserted.
In my case i needed to change an integer column called “log_weight” to a decimal. To achieve this, I had to alter 2 tables. Start with “field_config”, which contains all content type fields, defining the storage and front end render type. Now i likely could have used phpMyAdmin or some either database gui to make these updates, but i did not want to take the chance of missing out whatever internal queries drupal may run to log such actions. Here is the first query i ran directly in the themes template.php.
<?php db_query("UPDATE DATABASE_NAME.field_config SET type = 'number_decimal' WHERE field_config.field_name = 'field_log_weight'"); ?>
The last table I needed to update was “field_data_field_log_weight”.
<?php db_query("ALTER TABLE field_data_field_log_weight CHANGE field_log_weight_value field_log_weight_value DECIMAL(12,1) NULL DEFAULT NULL"); ?>
Once these queries were ran i could enter decimal values with ease! If your using views dont forget to update the field in that particular view to allow decimal rendering and specify scale.