Hi All,

I have drupal 6 working for a long time already. Database filled with hundreds of records. I use CCK fields for custom content. Now I've got a problem. I realized that I need to change type of one of the fields from integer to float. However I cannot do this via normal content type interface. Is there any way to do this?
I am already convinced to play with the drupal content database... but any clues where to start, what to do and if it is possible would be very helpful.

Thanks in advance for any ideas,
Krzysztof

Comments

Anonymous’s picture

I changed my filed record in content_node_field table, changed column type in content_type_mynodetype, resaved filed settings and it works for me

Marko B’s picture

I did just that but when crating new node i get

Fatal error: Class 'views_handler_filter_float' not found in C:\wamp\www\oglasnik\sites\all\modules\cck\includes\views\handlers\content_handler_filter_float.inc on line 9
array(4) { ["type"]=> int(1) ["message"]=> string(44) "Class 'views_handler_filter_float' not found" ["file"]=> string(99) "C:\wamp\www\oglasnik\sites\all\modules\cck\includes\views\handlers\content_handler_filter_float.inc" ["line"]=> int(9) } n/a

any ideas why? What else needs to be changeD?

tinem’s picture

Did you get it to functioning? I'm going to change from text to integer and want to know if this is the way to do it please?

Marko B’s picture

No had problems with that as my drupal installation is very complex, fortunately client gave up on this so i didnt have to do it afterall.

tinem’s picture

I found this explanation http://drupal.org/node/643646 which maybe can help someone. Haven't tried it myself. :-)

introfini’s picture

You also need to change the column 'type' in the 'content_node_field' table to 'number_float'

José Fernandes
Bloomidea

markwittens’s picture

For future reference and maybe to help out someone else here's how I converted an integer field to a float field:

  • Use the backend to create a new field with the correct type, the name doesn't matter since we will rename is later to the name of the existing field. Fill in the other options as you wish.
  • Execute the following query to populate the new field with the existing values:UPDATE content_type_<your content type> SET field_<new fieldname>_value = field_<old fieldname>_value
  • Execute the following queries to switch the original column with the new one (just to be safe we leave all original columns and records in the database):
    ALTER TABLE content_type_<your content type> CHANGE `field_<old fieldname>_value` `field_<old fieldname>_value_org` FLOAT NULL DEFAULT NULL 
    ALTER TABLE content_type_<your content type> CHANGE `field_<new fieldname>_value` `field_<old fieldname>_value` FLOAT NULL DEFAULT NULL 
    UPDATE content_node_field SET field_name = 'field_<old fieldname>_value_org' WHERE field_name = 'field_<old fieldname>_value';
    UPDATE content_node_field SET field_name = 'field_<new fieldname>_value' WHERE field_name = 'field_<old fieldname>_value';
  • Login to your Drupal site, edit the field and save it (this will clear some cache or something)
ankitchauhan’s picture

I think better way to do this
* First create another field with your content type
* Copy all the data of first field to newly created field as
update content_type_ SET new_Field = old_Field
* This will copy all the data to new field and now delete the old_field form content type.
* Again create the field in your content_type with new data type and use the above query again but revert the field name.

that0n3guy’s picture

Just for reference... the sql should be something like:

update content_type_contenttypehere SET new_Field_value = old_Field_value

Note: you need the _value after the field names.

nazia.briti’s picture

It has worked for me, thanks :)