Problem/Motivation

I feal totally puzzled.

I have two fields in six content types and user on D7 that are build with standard "textfield" and contain phone numbers. I'd like to convert them to "telephone" type during D7 to D10 migration to use the new field formater for tel fields. Is there any easy way or has someone done this and may share code with me, please? I guess it can only be easy as it is text to text migration, but I do not get the hand around any code example around.

I have already read more than 20 documentation pages about migrations and I do not understand what I really need to do as they are full of special cases. Any help is highly appreciated.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

marc.bau created an issue. See original summary.

marc.bau’s picture

Issue summary: View changes
mdsohaib4242’s picture

A more efficient approach would be to proceed with the migration from Drupal 7 to Drupal 10 as it is. Once the migration is complete, you can create a new "telephone" field in Drupal 10 and then transfer the data from the old field to the new one.

For example, if your content type is "article," and your existing field is `field_old` while the new telephone field is `field_new`, you can use a script to copy all the data.

$batch_size = 50;
$nids = \Drupal::entityQuery('node')
  ->condition('type', 'article')
  ->execute();
$nids_batches = array_chunk($nids, $batch_size);

foreach ($nids_batches as $batch) {
  $article_nodes = \Drupal\node\Entity\Node::loadMultiple($batch);

  foreach ($article_nodes as $article_node) {
    if (!$article_node->get('field_old')->isEmpty()) {
      $article_node->set('field_new', $article_node->get('field_old')->getValue());

      $article_node->save();
    }
  }
}

quietone’s picture

Status: Active » Closed (works as designed)

@marc.bau, I hope you resolved this. Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies.

There are several support options listed on our support page (Community > Support at the top of Drupal.org) and there is Drupal Slack. You may get better replies in one of those places. I suggest using the #migration channel in Drupal Slack.