You are here

function counter_update_7101 in Counter 7

Update: Rename field name and add index.

1 call to counter_update_7101()
counter_install in ./counter.install
Implements hook_install().

File

./counter.install, line 71
Install the module with a new database table

Code

function counter_update_7101() {
  if (db_field_exists('counter', 'counter_ip')) {
    db_change_field('counter', 'counter_ip', 'ip', array(
      'type' => 'varchar',
      'length' => 32,
      'not null' => TRUE,
      'default' => '',
    ));
  }
  if (db_field_exists('counter', 'counter_date')) {
    db_drop_field('counter', 'counter_date');
    db_add_field('counter', 'created', array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
    ));
  }
  if (db_field_exists('counter', 'counter_page')) {
    db_change_field('counter', 'counter_page', 'url', array(
      'type' => 'varchar',
      'length' => 256,
      'not null' => TRUE,
      'default' => '',
    ));
  }
  if (db_index_exists('counter', 'counter_date')) {
    db_drop_index('counter', 'counter_date');
  }
  if (db_index_exists('counter', 'counter_ip')) {
    db_drop_index('counter', 'counter_ip');
  }
  db_add_index('counter', 'created', array(
    'created',
  ));
  db_add_index('counter', 'ip', array(
    'ip',
  ));
}