You are here

function spambot_update_7101 in Spambot 8

Same name and namespace in other branches
  1. 7 spambot.install \spambot_update_7101()

Update variables, create new table 'node_spambot'.

File

./spambot.install, line 52
Install and update hooks for Spambot module.

Code

function spambot_update_7101() {
  $messages = [];

  // Create new table node_spambot.
  if (!\Drupal::database()
    ->schema()
    ->tableExists('node_spambot')) {
    $node_spambot = [
      'description' => t('Node table to track author IP addresses. For use by spambot only.'),
      'fields' => [
        'nid' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ],
        'uid' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ],
        'hostname' => [
          'type' => 'varchar',
          'length' => 128,
          'not null' => FALSE,
        ],
      ],
      'primary key' => [
        'nid',
      ],
      'indexes' => [
        'uid' => [
          'uid',
        ],
      ],
    ];
    \Drupal::database()
      ->schema()
      ->createTable('node_spambot', $node_spambot);
    $messages[] = t('Created new table <em>node_spambot</em>.');
  }
  return implode('<br />', $messages);
}