You are here

function _webform_legacy_update in Webform 5

Makes updates to the database structure (Pre-4.7 versions of Drupal).

1 call to _webform_legacy_update()
webform_update_1 in ./webform.install

File

./webform.install, line 401

Code

function _webform_legacy_update($installed_version, $current_version) {
  $ret = array();

  // Check to see if we should do a update.
  // Upgrading from original version
  if ($installed_version['build'] <= 1) {
    $ret[] = array(
      1 => "<strong>Build 1</strong><br />\n",
      2 => "",
    );

    // Add the table webform_submitted_data.
    $ret[] = update_sql("CREATE TABLE {webform_submited_data} " . "( nid int(10) unsigned not null, " . "sid int(10) unsigned not null, " . "name varchar(255) not null, " . "data blob, " . "PRIMARY KEY(nid, sid, name))");

    // Converting data from old submission table.

    //$ret[] = _webform_convert_old_submissions();
  }
  if ($installed_version['build'] <= 1) {

    //$ret[] = array(1 => "<strong>Build 4.5.0</strong><br />\n", 2 => "");

    // Change webform_component.extra from varchar(128) -> text.
    $ret[] = update_sql("ALTER TABLE {webform_component} MODIFY extra TEXT");

    // Change webform_submited_data.data blob -> longtext.
    $ret[] = update_sql("ALTER TABLE {webform_submited_data} MODIFY data LONGTEXT");
  }
  if ($installed_version['build'] < 460) {

    // $ret[] = array(1 => "<strong>Build 4.6.0</strong><br />\n", 2 => "");
    // Update webform_submited_data to webform_submitted_data.
    $ret[] = update_sql("ALTER TABLE {webform_submited_data} RENAME TO {webform_submitted_data}");
  }
  if ($installed_version['build'] < 461) {

    //$ret[] = array(1 => "<strong>Build 4.6.1</strong><br />\n", 2 => "");

    // Update webform.email varchar(50) -> varchar(255).
    $ret[] = update_sql(" ALTER TABLE {webform} MODIFY email varchar(255)");

    // Update from lable to label in webform_component.
    $ret[] = update_sql(" UPDATE {webform_component} SET type = 'label' WHERE type = 'lable'");
  }
  if ($installed_version['build'] < 462) {

    //$ret[] = array(1 => "<strong>Build 4.6.2</strong><br />\n", 2 => "");

    // Update webform.confirm varchar(255) -> text and change name to "confirmation".
    $ret[] = update_sql(" ALTER TABLE {webform} CHANGE confirm confirmation text");
  }
  if ($installed_version['build'] < 463) {

    //$ret[] = array(1 => "<strong>Build 4.6.3</strong><br />\n", 2 => "");

    // No more lazy update ...
    // Check if the lazy update has already been performed.
    $result = db_query("SHOW COLUMNS FROM {webform} LIKE 'email_subject'");
    if (db_num_rows($result) == 0) {

      // The email_subject column is needed.
      $ret[] = update_sql("ALTER TABLE {webform} ADD COLUMN email_subject varchar(255)");
    }
    $result = db_query("SHOW COLUMNS FROM {webform} LIKE 'email_from'");
    if (db_num_rows($result) == 0) {

      // The email_subject column is needed.
      $ret[] = update_sql("ALTER TABLE {webform} ADD COLUMN email_from varchar(255)");
    }
  }

  // Set the $current_version.
  variable_set("webform_version", $current_version);
  return $ret;
}