diff --git a/bin/dbsv-update.php b/bin/dbsv-update.php index 9181f04e..6c9fa041 100644 --- a/bin/dbsv-update.php +++ b/bin/dbsv-update.php @@ -165,4 +165,12 @@ ) ENGINE=MyISAM DEFAULT CHARSET=utf8"); } + function dbv_107() // sync of table definitions, developer and production system + { + sql("ALTER TABLE `caches` MODIFY `meta_last_modified` datetime NOT NULL COMMENT 'via Trigger (stat_caches, gk_item_waypoint)'"); + sql("ALTER TABLE `countries` MODIFY `en` varchar(128) NOT NULL"); + if (!sql_index_exists('cache_reports', 'userid')) + sql("ALTER TABLE `cache_reports` ADD INDEX `userid` (`userid`)"); + } + ?> \ No newline at end of file diff --git a/htdocs/doc/sql/tables/cache_reports.sql b/htdocs/doc/sql/tables/cache_reports.sql index 1ab8d3ac..7de2fa8f 100644 --- a/htdocs/doc/sql/tables/cache_reports.sql +++ b/htdocs/doc/sql/tables/cache_reports.sql @@ -12,5 +12,6 @@ CREATE TABLE `cache_reports` ( `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `status` (`status`,`adminid`), - KEY `status_2` (`adminid`,`status`) + KEY `status_2` (`adminid`,`status`), + KEY `userid` (`userid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='submitted reports on caches' ; diff --git a/htdocs/lib2/db.inc.php b/htdocs/lib2/db.inc.php index 4376bbb3..470c7dd0 100644 --- a/htdocs/lib2/db.inc.php +++ b/htdocs/lib2/db.inc.php @@ -1120,4 +1120,15 @@ '', $opt['db']['placeholder']['db'], $table, $field) ); } + // test if a database index exists + function sql_index_exists($table, $index) + { + global $opt; + + return sql_value("SELECT COUNT(*) + FROM `information_schema`.`statistics` + WHERE `table_schema`='&1' AND `table_name`='&2' AND `index_name`='&3'", + 0, $opt['db']['placeholder']['db'], $table, $index) > 0; + } + ?> \ No newline at end of file