=== modified file 'modules/system/system.install'
--- modules/system/system.install	2009-08-22 19:00:03 +0000
+++ modules/system/system.install	2009-08-23 07:29:43 +0000
@@ -2456,6 +2456,107 @@
 }
 
 /**
+ * Change profile.module fields into Field API fields.
+ */
+function system_update_7037() {
+  $ret = array();
+  
+  if (!db_table_exists('profile_field')) {
+    return $ret;
+  }
+  // Get all profile fields.
+  $fields = db_query('SELECT * FROM {profile_field} ORDER BY category, weight');
+
+  foreach ($fields as $old_field) {
+    // Create new fields using the field API.
+    $field = array(
+      'field_name' => strtolower(str_replace('-', '_', $old_field->name)),
+    );
+
+    // Create field instance on the user bundle.
+    $instance = array(
+      'field_name' => $field['field_name'],
+      'bundle' => 'user',
+      'description' => $old_field->explanation,
+      'label' => $old_field->title,
+      'required' => $old_field->required,
+      'widget' => array(
+        'weight' => $old_field->weight,
+      ),
+      'display' => array(
+        'full' => array(
+          'weight' => $old_field->weight,
+        ),
+      ),
+    );
+
+    switch ($old_field->type) {
+      case 'textfield':
+        $field['type'] = 'text';
+        $instance['widget']['type'] = 'text_textfield';
+
+        // Only allow plain text.
+        $instance['settings']['text_processing'] = 0;
+        break;
+
+      case 'textarea':
+        $field['type'] = 'text_long';
+        $instance['widget']['type'] = 'text_textarea';
+        // Use the default text format.
+        $instance['settings']['text_processing'] = variable_get('filter_default_format', 1);
+        break;
+
+      case 'checkbox':
+        $field['type'] = 'list_boolean';
+        $instance['widget']['type'] = 'options_onoff';
+        $field['settings']['allowed_values'] = "0\n1|" . $old_field->title;
+        break;
+
+      case 'selection':
+        $field['type'] = 'list_text';
+        $instance['widget']['type'] = 'options_select';
+        $field['settings']['allowed_values'] = $old_field->options;
+        break;
+
+      case 'list':
+        $field['type'] = 'text';
+        $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
+        break;
+
+      case 'date':
+        $ret[] = array('success' => TRUE, 'query' => 'To migrate date fields from the profile module, install the <a href="http://drupal.org/project/date">date</a> module.');        
+        continue 2;
+        
+      case 'url':
+        $ret[] = array('success' => TRUE, 'query' => 'To migrate URL fields from the profile module, install the <a href="http://drupal.org/project/link">link</a> module.');
+        continue 2;
+    }
+    
+    field_create_field($field);
+    field_create_instance($instance);
+  }
+
+  // Get old field values from the profile.module table.
+  $results = db_query('SELECT uid, name as field_name, value FROM {profile_field} f JOIN {profile_value} v ON f.fid = v.fid WHERE value IS NOT NULL');
+
+  $accounts = array();
+  foreach ($results as $result) {
+    $accounts[$result->uid]['uid'] = $result->uid;
+    $accounts[$result->uid][$result->field_name][0]['value'] = $result->value;
+  }
+
+  // Set new field values using the field API.
+  foreach ($accounts as $account) {
+    $account = (object) $account;
+    field_attach_update('user', $account);
+  }
+    
+  $ret[] = array('success' => TRUE, 'query' => 'The profile module has been replaced by the new Fields UI. For additional functionality such as adding fields to the registration form, install the <a href="http://drupal.org/project/retro_profile">Retro Profile</a> module.');
+  
+  return $ret; 
+}
+
+/**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */

