search_files.install in Search Files 6.2
Same filename and directory in other branches
Installation and update procedures for the search_files module.
File
search_files.installView source
<?php
/**
* @file
* Installation and update procedures for the search_files module.
*/
function search_files_schema() {
$schema['search_files_helpers'] = array(
'description' => t('list of programs that translate the file to test to be indexed'),
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'disp-width' => '11',
),
'name' => array(
'type' => 'varchar',
'length' => '50',
'not null' => FALSE,
),
'extension' => array(
'type' => 'varchar',
'length' => '10',
'not null' => FALSE,
),
'helper_path' => array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
),
'indexes' => array(
'id' => array(
'id',
),
),
);
return $schema;
}
function search_files_install() {
drupal_install_schema('search_files');
//change variable search_cron_limit to 10 so cron doesn't keep timing out
if (variable_get('search_cron_limit', 100) > 10) {
variable_set('search_cron_limit', 10);
drupal_set_message(t('Your search cron limit, which limits the number of items searched per cron run, has been set to 10. If it had been left at the default 100 your cron jobs could potentially continuously timeout. If you want to change this back you can do so <a href="!link">here</a>', array(
'!link' => url('admin/settings/search'),
)));
}
}
/* http://drupal.org/node/114774#update-n
*/
function search_files_update_6200() {
$ret = array();
return $ret;
}
function search_files_update_6201() {
$ret = array();
/* rename variables */
search_files_variable_rename_ifexists('search_files_cron_limit', 'search_cron_limit');
return $ret;
}
function search_files_update_6202() {
$ret = array();
db_change_field($ret, 'search_files_helpers', 'helper_path', 'helper_path', array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
));
return $ret;
}
function search_files_update_6203() {
$ret = array();
/* add PostgreSQL support for concat() with three args, inspired by http://drupal.org/node/83974
* taken from modules/system/system.install which already does the same trick for concat() with two args
*/
if ($GLOBALS['db_type'] == 'pgsql') {
if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat' AND pronargs = 3"))) {
db_query("\n CREATE OR REPLACE FUNCTION concat(text, text, text)\n RETURNS text AS\n 'SELECT \$1 || \$2 || \$3;'\n LANGUAGE 'sql'\n ");
}
}
return $ret;
}
/* rename table if it exists, otherwise skip silently */
function search_files_db_rename_table_ifexists(&$ret, $table, $new_name) {
if (db_table_exists($table)) {
db_rename_table($ret, $table, $new_name);
}
}
/* rename column if it exists, otherwise skip silently */
function search_files_db_rename_column_ifexists(&$ret, $table, $column, $new_name, $spec) {
if (db_table_exists($table)) {
if (db_column_exists($table, $column)) {
db_change_field($ret, $table, $column, $new_name, $spec);
}
}
}
/* rename variable if it exists, otherwise skip silently */
function search_files_variable_rename_ifexists($name, $new_name) {
global $conf;
if ($name != $new_name and isset($conf[$name])) {
variable_set($new_name, variable_get($name, NULL));
variable_del($name);
}
}
function search_files_uninstall() {
drupal_uninstall_schema('search_files');
db_query("DELETE FROM {variable} WHERE name LIKE 'search_files_%'");
}
Functions
Name | Description |
---|---|
search_files_db_rename_column_ifexists | |
search_files_db_rename_table_ifexists | |
search_files_install | |
search_files_schema | @file Installation and update procedures for the search_files module. |
search_files_uninstall | |
search_files_update_6200 | |
search_files_update_6201 | |
search_files_update_6202 | |
search_files_update_6203 | |
search_files_variable_rename_ifexists |