Changing a field settings on a live site in Drupal7 In the middle of entering content I discovered the length of 15 characters of a particular field I set earlier is not enough. 

In Drupal6 I could change the settings of a cck field. It could be potentially dangerous, but in my case it's a lossless transform, I just want to make a maximum size of a field a little longer.

But in Drupal7 I get the message saying it's impossible to change the field settings because there is some content stored in that field in database.

This restriction seems too strict to me. A warning message seems to be enough. 

So my question is what's the reasons for this behavior and what can be done in my case? Manual deleting and recreating the content is not the option.
Unlike in Drupal 6 where setting the max length of a text field didn't have any influence on the database, but merely added a validation check, Drupal 7 will actual create a column that can only hold the selected number of chars.

You can get around this, but not though the UI, as you need to alter the table in the database.

What you need to do is alter the max length of the value column in the field tables named:


field_data_[FIELD NAME]
field_revision_[FIELD NAME]


The column you need to change should be called [FIELD_NAME]_value

Then you need to alter the configuration, which is serialized data in the data column in the field_config table for the field. You can either edit it directly if you are familiar with PHP serialized data or can do it with drupal_write_record. I believe the usual API function field_update_field wont work, as it should throw an exception not allowing the field to be saved, you can however use field_info_field to get the field data as it is stored in the database.

So in short, it can be done, but requires some custom hacking on the DB not using proper APIs.

An alternative solution would be to create a new field and migrate the data and then delete the old field.