=== modified file 'modules/system/system.install'
--- modules/system/system.install	2009-02-25 13:33:53 +0000
+++ modules/system/system.install	2009-03-07 22:27:11 +0000
@@ -3226,6 +3226,100 @@
 }
 
 /**
+ * Change profile.module fields into Field API fields.
+ */
+function system_update_7020() {
+  // TODO: enable the text, list and options modules.
+  
+  // 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' => $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,
+      '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'] = 1;
+        break;
+        
+      case 'checkbox':
+        $field['type'] = 'list_boolean';
+        $instance['widget']['type'] = 'options_onoff';
+        // TODO: get allowed values.
+        break;
+        
+      case 'selection':
+        $field['type'] = 'list_text';
+        $instance['widget']['type'] = 'options_select';
+        // TODO: get allowed values.
+        break;
+        
+      case 'list':
+        $field['type'] = 'text';
+        $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
+        break;
+        
+      case 'date':
+        $field['type'] = 'text';
+        // TODO: figure out what to do with this. date.module in core?
+        break;
+        
+      case 'url':
+        $field['type'] = 'text';
+        // This is kind of a hack to turn the URL into a link using the URL filter.
+        $instance['settings']['text_processing'] = 1;
+        break;
+    }
+    
+    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);
+  }
+  
+  // Remove profile fields and data.
+  db_delete('profile_field')->execute();
+  db_delete('profile_value')->execute();
+}
+
+/**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */

