diff --git a/radioactivity.install b/radioactivity.install
index 89179f9..db97792 100644
--- a/radioactivity.install
+++ b/radioactivity.install
@@ -170,6 +170,216 @@ function radioactivity_schema() {
 }
 
 /**
+ * Create new Drupal 7 database table structure.
+ */
+function radioactivity_update_7000() {
+  // Create the new database tables. Note this doesn't match hook_schema above,
+  // because it matches the original Drupal 7 schema. Further updates in the
+  // 72xx numbers bring the schema up to date.
+  $schema = array();
+
+  $schema['radioactivity_deferred_storage'] = array(
+    'description' => 'Deferred storage table for radioactivity',
+    'fields' => array(
+      'entity_type' => array(
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'description' => 'Entity type'
+      ),
+      'field_name' => array(
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'description' => 'Field name'
+      ),
+      'bundle' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'description' => 'Bundle'
+      ),
+      'entity_id' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'Entity ID'
+      ),
+      'energy' => array(
+        'type' => 'float',
+        'size' => 'big',
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'Amount of energy this action produced'
+      ),
+      'emission_time' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'Time of the emission'
+       ),
+     ),
+
+     //'primary key' => array('entity_type', 'entity_id', 'field_id'),
+     'indexes' => array('main' => array('entity_type', 'field_name', 'bundle', 'entity_id')),
+
+  );
+
+  $schema['radioactivity_decay_profile'] = array(
+    'description' => 'Radioactivity decay profiles',
+    'fields' => array(
+      'machine_name' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'description' => 'Machine name for the profile'
+      ),
+      'name' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'description' => 'Name for the profile'
+      ),
+      'description' => array(
+        'type' => 'text',
+        'not null' => FALSE,
+        'description' => 'Description'
+      ),
+      'granularity' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '60',
+        'description' => 'Accuracy of the modelling'
+      ),
+      'half_life' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => "21600",
+        'description' => 'Half life'
+      ),
+      'cut_off' => array(
+        'type' => 'float',
+        'size' => 'big',
+        'not null' => TRUE,
+        'default' => "0.1",
+        'description' => 'Cut off'
+      ),
+      'storage' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => 'live',
+        'description' => 'Storage type for the profile'
+       ),
+     ),
+     'primary key' => array('machine_name')
+  );
+
+  db_create_table('radioactivity_deferred_storage', $schema['radioactivity_deferred_storage']);
+  db_create_table('radioactivity_decay_profile', $schema['radioactivity_decay_profile']);
+}
+
+/**
+ * Migrate Radioactivity profiles.
+ */
+function radioactivity_update_7001(&$sandbox) {
+  module_load_include('module', 'radioactivity');
+  $profiles = variable_get('radioactivity_profiles', array());
+  foreach ($profiles as $old_profile) {
+    $profile = array(
+      'machine_name' => str_replace('-', '_', drupal_html_id($old_profile['label'])),
+      'name' => $old_profile['label'],
+      'description' => $old_profile['description'],
+      'granularity' => 60,
+      'half_life' => $old_profile['half_life'],
+      'cut_off' => $old_profile['cut_off_energy'],
+      'storage' => 'live',
+    );
+    radioactivity_decay_profile_save($profile);
+  }
+  variable_del('radioactivity_profiles');
+
+  // Ensure module is enabled for the next update.
+  if (!module_exists('radioactivity')) {
+    module_enable(array('radioactivity'));
+    field_cache_clear();
+  }
+}
+
+/**
+ * Create new Radioactivity fields.
+ */
+function radioactivity_update_7002() {
+  // Create the radioactivity field itself.
+  $field = array(
+    'field_name' => 'field_radioactivity',
+    'type' => 'radioactivity',
+  );
+  field_create_field($field);
+
+  // Create instances of the radioactivity field.
+  $result = db_query("SELECT r.class, n.type FROM {radioactivity} r INNER JOIN {node} n ON r.id = n.nid AND r.class = 'node' GROUP BY n.type, r.class");
+  foreach ($result as $row) {
+    // Skip nodes without a valid type.
+    if ($row->class === 'node' && empty($row->type)) {
+      continue;
+    }
+
+    $field_instance = array(
+      'field_name' => 'field_radioactivity',
+      'entity_type' => $row->class,
+      'bundle' => $row->class === 'node' ? $row->type : $row->class,
+      'label' => 'Radioactivity energy',
+      'settings' => array(
+        'profile' => $sandbox['default_profile'],
+      ),
+    );
+    field_create_instance($field_instance);
+  }
+}
+
+/**
+ * Upgrade Drupal 6 Radioactivity data to the new structure.
+ */
+function radioactivity_update_7003(&$sandbox) {
+  // First time setup tasks.
+  if (!isset($sandbox['max_id'])) {
+    // Initialize counts.
+    $sandbox['max_id'] = db_query("SELECT MAX(id) FROM {radioactivity}")->fetchField();
+    $sandbox['last_id'] = 0;
+    $sandbox['default_profile'] = db_query("SELECT machine_name FROM {radioactivity_decay_profile} LIMIT 1")->fetchField();
+  }
+
+  $row_count = 500;
+  $result = db_query_range("SELECT * FROM {radioactivity} r LEFT JOIN {node} n ON r.id = n.nid AND r.class = 'node' WHERE id > :id", 0, $row_count, array(':id' => $sandbox['last_id']));
+  foreach ($result as $row) {
+    $sandbox['last_id'] = $row->id;
+    $bundle = $row->type ? $row->type : $row->class;
+    _radioactivity_update_energy($row->class, $bundle, 'field_radioactivity', LANGUAGE_NONE, $row->id, $row->energy, $row->last_emission_timestamp, TRUE);
+  }
+
+  if (empty($sandbox['max_id']) || $sandbox['max_id'] === $sandbox['last_id']) {
+    $sandbox['#finished'] = 1;
+    field_cache_clear();
+  }
+  else {
+    $sandbox['#finished'] = $sandbox['last_id'] / $sandbox['max_id'];
+  }
+}
+
+/**
+ * Remove old Drupal 6 Radioacitivy data.
+ */
+function radioactivity_update_7004() {
+  db_drop_table('radioactivity');
+  db_drop_table('radioactivity_node_clicks');
+}
+
+/**
  * Add a new field for radioactivity_decay_profile, and drop some variables
  */
 function radioactivity_update_7200() {
