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

Update variables, create new table 'node_spambot'.

File

./spambot.install, line 52

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);
}