spam.install in Spam 6
Same filename and directory in other branches
Defines Spam module schema.
File
spam.installView source
<?php
/**
* @file
* Defines Spam module schema.
*/
/**
*
*/
function spam_schema() {
$schema['spam_tracker'] = array(
'fields' => array(
'sid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '11',
),
'content_type' => array(
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
),
'content_id' => array(
'type' => 'varchar',
'length' => '32',
'not null' => TRUE,
'default' => '',
),
'score' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'disp-width' => '4',
),
'hostname' => array(
'type' => 'varchar',
'length' => '15',
'not null' => TRUE,
'default' => '',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'disp-width' => '11',
),
),
'primary key' => array(
'sid',
),
'unique keys' => array(
'content_id_content_type' => array(
'content_id',
'content_type',
),
),
'indexes' => array(
'content_type' => array(
'content_type',
),
'hostname' => array(
'hostname',
),
'score' => array(
'score',
),
'timestamp' => array(
'timestamp',
),
),
);
$schema['spam_statistics'] = array(
'fields' => array(
'stid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '11',
),
'name' => array(
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'default' => '',
),
'count' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '11',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'disp-width' => '11',
),
),
'primary key' => array(
'stid',
),
'unique keys' => array(
'name' => array(
'name',
),
),
);
$schema['spam_log'] = array(
'fields' => array(
'lid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '11',
),
'trid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '11',
),
'level' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '2',
),
'content_type' => array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
'default' => '',
),
'content_id' => array(
'type' => 'varchar',
'length' => '32',
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'function' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'message' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'hostname' => array(
'type' => 'varchar',
'length' => '15',
'not null' => TRUE,
'default' => '',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'disp-width' => '11',
),
),
'primary key' => array(
'lid',
),
'indexes' => array(
'content_type_content_id' => array(
'content_type',
'content_id',
),
'hostname' => array(
'hostname',
),
'message' => array(
'message',
),
'timestamp' => array(
'timestamp',
),
'trid' => array(
'trid',
),
'uid' => array(
'uid',
),
),
);
$schema['spam_filters_errors'] = array(
'fields' => array(
'bid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '11',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '11',
),
'language' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
'content_type' => array(
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
),
'content_id' => array(
'type' => 'varchar',
'length' => '32',
'not null' => TRUE,
'default' => '',
),
'content_hash' => array(
'type' => 'char',
'length' => '32',
'not null' => TRUE,
'default' => '',
),
'content' => array(
'type' => 'text',
'not null' => TRUE,
),
'form' => array(
'type' => 'text',
'not null' => TRUE,
),
'feedback' => array(
'type' => 'text',
'not null' => TRUE,
),
'hostname' => array(
'type' => 'varchar',
'length' => '15',
'not null' => TRUE,
'default' => '',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'disp-width' => '11',
),
),
'primary key' => array(
'bid',
),
'unique keys' => array(
'content_hash' => array(
'content_hash',
),
),
'indexes' => array(
'content_type' => array(
'content_type',
),
'hostname' => array(
'hostname',
),
'id_type' => array(
'content_id',
'content_type',
),
'timestamp' => array(
'timestamp',
),
),
);
$schema['spam_filters'] = array(
'fields' => array(
'fid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '11',
),
'gid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '11',
),
'name' => array(
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
),
'module' => array(
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
),
'status' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'disp-width' => '3',
),
'weight' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'disp-width' => '4',
),
'gain' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'disp-width' => '3',
),
),
'primary key' => array(
'fid',
),
'indexes' => array(
'gid' => array(
'gid',
),
'module' => array(
'module',
),
'name' => array(
'name',
),
'status' => array(
'status',
),
'weight' => array(
'weight',
),
),
);
return $schema;
}
function spam_install() {
// Create my tables.
drupal_install_schema('spam');
}
function spam_uninstall() {
// Remove tables.
drupal_uninstall_schema('spam');
drupal_set_message(t('All spam module tables have been deleted.'));
}
/**
* Allow for non-integer spam IDs
*/
function spam_update_6001() {
$ret = array();
db_drop_unique_key($ret, 'spam_tracker', 'content_id_content_type');
db_change_field($ret, 'spam_tracker', 'content_id', 'content_id', array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
), array(
'unique keys' => array(
'content_id_content_type' => array(
'content_id',
'content_type',
),
),
));
db_drop_index($ret, 'spam_log', 'content_type_content_id');
db_change_field($ret, 'spam_log', 'content_id', 'content_id', array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
), array(
'indexes' => array(
'content_type_content_id' => array(
'content_type',
'content_id',
),
),
));
db_drop_index($ret, 'spam_filters_errors', 'id_type');
db_change_field($ret, 'spam_filters_errors', 'content_id', 'content_id', array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
), array(
'indexes' => array(
'id_type' => array(
'content_id',
'content_type',
),
),
));
return $ret;
}
/**
* Add language field to spam_filters_errors table.
*/
function spam_update_6002() {
$ret = array();
db_add_field($ret, 'spam_filters_errors', 'language', array(
'type' => 'varchar',
'length' => 12,
'default' => '',
'not null' => TRUE,
));
return $ret;
}
/**
* Drop unused fields/tables
*/
function spam_update_6003() {
$ret = array();
db_drop_table($ret, 'spam_filters_groups');
db_drop_table($ret, 'spam_filters_groups_data');
db_drop_index($ret, 'spam_filters', 'gid');
db_drop_field($ret, 'spam_filters', 'gid');
return $ret;
}
Functions
Name | Description |
---|---|
spam_install | |
spam_schema | |
spam_uninstall | |
spam_update_6001 | Allow for non-integer spam IDs |
spam_update_6002 | Add language field to spam_filters_errors table. |
spam_update_6003 | Drop unused fields/tables |