search_files_directories.install in Search Files 7.2
Same filename and directory in other branches
Installation and update procedures for the search directories module.
File
search_files_directories.installView source
<?php
/**
* @file
* Installation and update procedures for the search directories module.
*/
function search_files_directories_schema() {
$schema['search_files_directories_directories'] = array(
'description' => 'list of directories that we will index',
'fields' => array(
'id' => array(
'description' => 'unique id of the directory',
'type' => 'serial',
'not null' => TRUE,
),
'filepath' => array(
'description' => 'the system path of the directory',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'uripath' => array(
'description' => 'the web path for the directory',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
),
'primary key' => array(
'id',
),
'unique keys' => array(
'filepath' => array(
'filepath',
),
),
);
$schema['search_files_directories_files'] = array(
'description' => 'list of files in the directories',
'fields' => array(
'id' => array(
'description' => 'the unique id of the file',
'type' => 'serial',
'not null' => TRUE,
),
'path' => array(
'description' => 'the path of the file in the parent directory',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'directory_id' => array(
'description' => 'the parent directory',
'type' => 'int',
'not null' => TRUE,
),
'index_attempts' => array(
'description' => 'how many times we have attempted to index this file',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
),
),
'primary key' => array(
'id',
),
'unique keys' => array(
'path' => array(
'path',
'directory_id',
),
),
);
return $schema;
}
function search_files_directories_install() {
//drupal_install_schema('search_files_directories');
}
/**
* Update #1 - Migrate from search_files-1.x to search_files-2.x
*/
function search_files_directories_update_1() {
$ret = array();
if (db_table_exists('search_files_files')) {
db_rename_table($res, 'search_files_files', 'search_files_directories_files');
}
variable_set('search_files_directories_tab_label', variable_get('search_files_label', NULL));
variable_del('search_files_label');
variable_set('search_files_directories_last_index', variable_get('search_files_last_index', 0));
variable_del('search_files_last_index');
return $ret;
}
/* http://drupal.org/node/114774#update-n
*/
function search_files_directories_update_6200() {
$ret = array();
/* take over module enablement and discard obsolete module information */
$result = db_result(db_query_range("\n SELECT status FROM {system}\n WHERE name = 'search_directories'\n AND filename LIKE '%/search_files/modules/search_directories/search_directories.module'\n "), 0, 1);
if ($result != "") {
db_query("\n UPDATE {system}\n SET status = '%s'\n WHERE name = 'search_files_directories'\n ", $result);
db_query("\n DELETE FROM {system}\n WHERE name = 'search_directories'\n AND filename LIKE '%/search_files/modules/search_directories/search_directories.module'\n ");
}
/* rename tables */
search_files_db_rename_table_ifexists($ret, 'search_directories', 'search_files_directories');
search_files_db_rename_table_ifexists($res, 'search_directories_files', 'search_files_directories_files');
/* rename variables */
search_files_variable_rename_ifexists('search_directories_last_index', 'search_files_directories_last_index');
search_files_variable_rename_ifexists('search_directories_tab_disabled', 'search_files_directories_tab_disabled');
search_files_variable_rename_ifexists('search_directories_tab_label', 'search_files_directories_tab_label');
search_files_variable_rename_ifexists('search_files_directoryrescanage', 'search_files_directories_rescanage');
return $ret;
}
function search_files_directories_update_6201() {
$ret = array();
db_query("\n UPDATE search_dataset\n SET type = 'search_files_dir'\n WHERE ( type = 'search_files' OR type = 'search_directories')\n ");
db_query("\n UPDATE search_index\n SET type = 'search_files_dir'\n WHERE ( type = 'search_files' OR type = 'search_directories')\n ");
return $ret;
}
function search_files_directories_update_6202() {
$ret = array();
search_files_db_rename_table_ifexists($ret, 'search_files_directories', 'search_files_directories_directories');
return $ret;
}
function search_files_directories_update_6203() {
$ret = array();
search_files_db_rename_column_ifexists($ret, 'search_files_directories_directories', 'directory', 'path', array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
));
search_files_db_rename_column_ifexists($ret, 'search_files_directories_files', 'full_path', 'path', array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
));
return $ret;
}
function search_files_directories_update_6204() {
$ret = array();
search_files_db_rename_column_ifexists($ret, 'search_files_directories_directories', 'path', 'filepath', array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
));
db_add_field($ret, 'search_files_directories_directories', 'uripath', array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
));
return $ret;
}
function search_files_directories_uninstall() {
db_query("DELETE FROM {search_dataset} WHERE type = 'search_files_dir'");
db_query("DELETE FROM {search_index} WHERE type = 'search_files_dir'");
db_query("DELETE FROM {variable} WHERE name LIKE 'search_files_directories_%'");
variable_set('search_default_module', 'node');
}
Functions
Name | Description |
---|---|
search_files_directories_install | |
search_files_directories_schema | @file Installation and update procedures for the search directories module. |
search_files_directories_uninstall | |
search_files_directories_update_1 | Update #1 - Migrate from search_files-1.x to search_files-2.x |
search_files_directories_update_6200 | |
search_files_directories_update_6201 | |
search_files_directories_update_6202 | |
search_files_directories_update_6203 | |
search_files_directories_update_6204 |