View source
<?php
function search_files_install() {
switch ($GLOBALS['db_type']) {
case 'pgsql':
break;
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {search_files_directories} (\n \t\t`id` int(11) NOT NULL auto_increment,\n \t\t`directory` varchar(150) NOT NULL default '',\n\t\tPRIMARY KEY (`id`),\n \t\tUNIQUE KEY `directory` (`directory`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\t");
db_query("\n\t\tCREATE TABLE {search_files_files} (\n\t\t`id` int(11) NOT NULL auto_increment,\n\t\t`full_path` varchar(255) NOT NULL default '',\n\t\t`directory_id` int(11) NOT NULL default '0',\n\t\t`index_attempts` tinyint(4) NOT NULL default '0',\n\t\tPRIMARY KEY (`id`),\n\t\tUNIQUE KEY `full_path` (`full_path`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\t");
db_query("\t\t\n\t\tCREATE TABLE {search_files_helpers} (\n\t\t`id` int(11) NOT NULL auto_increment,\n\t\t`name` varchar(50) default NULL,\n\t\t`extension` varchar(10) default NULL,\n\t\t`helper_path` varchar(100) default NULL,\n\t\tKEY `id` (`id`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\t");
db_query(" \n CREATE TABLE {search_files_reindex} (\n `sid` int(10) unsigned ,\n `reindex` int(11) ,\n PRIMARY KEY (`sid`) \n ) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n ");
break;
case 'mssql':
db_query("CREATE TABLE search_files_directories (\n id int NOT NULL IDENTITY(1,1),\n directory varchar(150) NOT NULL default '' UNIQUE,\n PRIMARY KEY (id),\n );");
db_query("\n CREATE TABLE search_files_files (\n id int NOT NULL IDENTITY(1,1),\n full_path varchar(255) NOT NULL default '' UNIQUE,\n directory_id int NOT NULL default '0',\n index_attempts smallint NOT NULL default '0',\n PRIMARY KEY (id)\n )");
db_query("\n CREATE TABLE search_files_helpers (\n id int NOT NULL IDENTITY(1,1),\n name varchar(50) NULL default NULL,\n extension varchar(10) NULL default NULL,\n helper_path varchar(100) NULL default NULL\n )");
db_query("CREATE INDEX {search_files_helpers}_id_idx ON {search_files_helpers} (id)");
db_query("\n CREATE TABLE search_files_reindex (\n sid int NOT NULL DEFAULT 0,\n reindex int NULL DEFAULT NULL,\n PRIMARY KEY (sid)\n )");
}
}
function search_files_uninstall() {
db_query('DROP TABLE {search_files_directories}');
db_query('DROP TABLE {search_files_files}');
db_query('DROP TABLE {search_files_helpers}');
db_query('DROP TABLE {search_files_reindex}');
db_query('DELETE FROM {search_dataset} WHERE TYPE LIKE "search_files"');
db_query('DELETE FROM {search_index} WHERE TYPE LIKE "search_files"');
variable_del('search_files_label');
}