You are here

function cleantalk_update_81411 in Anti Spam by CleanTalk 8.4

File

./cleantalk.install, line 403
Install and uninstall functions, schema definition for the CleanTalk module.

Code

function cleantalk_update_81411(&$sandbox) {
  \Drupal::service('database')
    ->schema()
    ->dropTable('cleantalk_sfw');
  \Drupal::service('database')
    ->schema()
    ->dropTable('cleantalk_sfw_logs');
  \Drupal::service('database')
    ->schema()
    ->dropTable('cleantalk_ac_logs');
  \Drupal::service('database')
    ->schema()
    ->dropTable('cleantalk_ac_ua_bl');
  $cleantalk_sfw_table_schema = array(
    'description' => 'SpamFireWall data.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'description' => "ID",
        'length' => 11,
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'network' => array(
        'type' => 'int',
        'length' => 11,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Spam network.',
      ),
      'mask' => array(
        'type' => 'int',
        'length' => 11,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Spam mask.',
      ),
      'status' => array(
        'type' => 'int',
        'length' => 1,
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Spam status.',
      ),
      'source' => array(
        'type' => 'int',
        'length' => 1,
        'unsigned' => FALSE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'Source.',
      ),
    ),
    'indexes' => array(
      'network' => array(
        'network',
        'mask',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $cleantalk_sfw_logs_table_schema = array(
    'description' => 'SpamFireWall logs.',
    'fields' => array(
      'id' => array(
        'type' => 'varchar',
        'length' => 40,
        'not null' => true,
        'description' => 'ID.',
      ),
      'ip' => array(
        'type' => 'varchar',
        'length' => 15,
        'not null' => TRUE,
        'description' => 'IP.',
      ),
      'status' => array(
        'type' => 'varchar',
        'length' => 50,
        'description' => 'status',
        'not null' => false,
        'default' => NULL,
      ),
      'all_entries' => array(
        'type' => 'int',
        'description' => 'All entries.',
      ),
      'blocked_entries' => array(
        'type' => 'int',
        'description' => 'Blocked entries.',
      ),
      'entries_timestamp' => array(
        'type' => 'int',
        'description' => 'time().',
      ),
      'ua_id' => array(
        'type' => 'int',
        'description' => 'ua_id',
        'length' => 11,
        'not null' => FALSE,
        'default' => NULL,
        'unsigned' => true,
      ),
      'ua_name' => array(
        'type' => 'varchar',
        'description' => 'ua_name',
        'length' => 1024,
        'not null' => TRUE,
      ),
      'source' => array(
        'type' => 'int',
        'length' => 1,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'network' => array(
        'type' => 'varchar',
        'length' => 20,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'first_url' => array(
        'type' => 'varchar',
        'length' => 100,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'last_url' => array(
        'type' => 'varchar',
        'length' => 100,
        'not null' => FALSE,
        'default' => NULL,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $cleantalk_ac_logs_table_schema = array(
    'description' => 'AntiCrawler logs.',
    'fields' => array(
      'id' => array(
        'type' => 'varchar',
        'length' => 40,
        'not null' => true,
        'description' => 'ID.',
      ),
      'ip' => array(
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'description' => 'IP.',
      ),
      'ua' => array(
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'description' => 'UA.',
      ),
      'entries' => array(
        'type' => 'int',
        'length' => 11,
        'description' => 'Entries.',
        'not null' => TRUE,
        'default' => 0,
      ),
      'interval_start' => array(
        'type' => 'int',
        'length' => 11,
        'not null' => TRUE,
        'description' => 'interval_start.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $cleantalk_ac_ua_bl_table_schema = array(
    'description' => 'AntiCrawler User-Agent Blacklist.',
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'length' => 11,
        'not null' => true,
        'description' => 'ID.',
      ),
      'ua_template' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'ua_status' => array(
        'type' => 'int',
        'length' => 1,
        'not null' => FALSE,
      ),
    ),
    'indexes' => array(
      'network' => array(
        'ua_template',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  \Drupal::service('database')
    ->schema()
    ->createTable('cleantalk_sfw', $cleantalk_sfw_table_schema);
  \Drupal::service('database')
    ->schema()
    ->createTable('cleantalk_sfw_logs', $cleantalk_sfw_logs_table_schema);
  \Drupal::service('database')
    ->schema()
    ->createTable('cleantalk_ac_logs', $cleantalk_ac_logs_table_schema);
  \Drupal::service('database')
    ->schema()
    ->createTable('cleantalk_ac_ua_bl', $cleantalk_ac_ua_bl_table_schema);
}