You are here

function maillog_update_7100 in Maillog / Mail Developer 7

Rename the 'idmaillog' field to just 'id'.

File

./maillog.install, line 158
Provides the installation routines for the maillog module.

Code

function maillog_update_7100() {
  if (!db_field_exists('maillog', 'id')) {

    // Add the new 'id' field.
    $spec = array(
      'type' => 'int',
      'not null' => TRUE,
      'unsigned' => TRUE,
      'default' => 0,
      'description' => "The primary key of this table.",
    );
    db_add_field('maillog', 'id', $spec);

    // Fill in all of the 'id' fields.
    db_query("UPDATE {maillog} SET id=idmaillog");

    // Drop the 'idmaillog' field
    db_drop_field('maillog', 'idmaillog');

    // Change the 'id' field to a serial.
    $spec = array(
      'type' => 'serial',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => "The primary key of this table.",
    );
    $keys = array(
      'primary key' => array(
        'id',
      ),
    );
    db_change_field('maillog', 'id', 'id', $spec, $keys);
  }
}