2

Here is my case.

  1. I've created a content type with few fields (all fields had type: 'text').
  2. I've exported this content type using feature and then used feature on PROD website for few weeks.
  3. Recently we decided to change type of 2 fields to: 'email' and 'link' (first we deleted these 2 fields, and then created them with new type), I've updated feature with my content type again (since we did changes to these 2 fields).
  4. Now when I do deploy to my website it says that it can't convert fields form current type to new type (and I can understand that). However I also believe it is something that everybody does, so there must be a normal solution to this.

Here is a message from my terminal:

WD php: FieldException: Cannot change an existing field's type. in field_update_field() (line 234 of /Users/aaa/git/drupal/http/modules/field/field.crud.inc).
[error] Drush command terminated abnormally due to an unrecoverable error.
[error] FieldException: Cannot change an existing field's type. in field_update_field() (line 234 of /Users/aaa/git/drupal/http/modules/field/field.crud.inc).

Please advise what is the good approach to solve my issue (change type of field that is used already).

1
  • 1
    The basic idea is in the top answer here: drupal.stackexchange.com/questions/79378/…. Link (and maybe email fields too) have more columns than a text field, though, so you'll also need to add those and use the correct suffix (i.e. not _value). You should be able to find the column schema in each module's .install file in hook_field_schema
    – Clive
    Commented Jul 9, 2015 at 12:52

1 Answer 1

1

A possible approach to avoid running into this commonly known challenge, is to perform a mini-migration for each of both of your fields, on your PROD website.

Here are the highlights of such approach:

  1. For your eMail field:

    • Assume your existing field (with type text) has machine name field_email.
    • Create a new field with type eMail (instead of text), say with machine name field_email_new.
  2. For your Link field:

    • Assume your existing field (with type text) has machine name field_link.
    • Create a new field with type eMail (instead of text), say with machine name field_link_new.
  3. Deploy both fields field_email_new and field_link_new to your PROD site, using Features (similar to what you tried to use, but which failed). Since these are new fields, that should not cause similar problems. Obviously, at that point the values of these fields will be empty.

  4. For each of both fields, use an approach similar to what I described in my answer to "How do I move content from one field to another?", which (only) uses modules Rules and Views Bulk Operations. You should be able to reuse the Rules Component included there, after adapting the machine names of the used fields.

  5. To the extend that would be needed, don't forget to adapt custom Rules, Views, etc to reference the new (instead of old) machine names of both fields.

  6. Delete the original (old) eMail field and Link field.

  7. Double check your custom Rules, Views, etc that you (should have) modified in 'Step 5' above, to ensure you don't have any of the typically "integrity" error messages (because you forget or skipped some of them). If any such errors show up, adapt the machine names to the new ones to fix them.

Obviously, steps 5, 6 and 7 can be refined by creating a clone from your PROD site, and prepare that kind of work in some none-PROD equivalent. Possibly combined with using a Features based deployment procedure to migrate your changes from that clone to your PROD site afterwards.

Note: NO custom coding, only some (rather basic) admin stuff, using robust contributed modules (and which can be uninstalled again afterwards).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.