/** * Create an index using the suitable SQL for various RDBMS. * * @since 1.8 * @param DatabaseBase|Database $db Database handler * @param string $type "INDEX", "UNIQUE" or similar * @param string $indexName name fo the index as in DB * @param string $tableName name of the table * @param array $columns list of column names to index, comma separated * @param object $reportTo object to report messages to */ private static function createIndex($db, $type, $indexName, $tableName, $columns, $reportTo = null) { global $wgDBtype; self::reportProgress(" ... creating new index {$columns} ...", $reportTo); if ($wgDBtype == 'postgres') { // postgresql if ($db->indexInfo($tableName, $indexName) === false) { $db->query("CREATE {$type} {$indexName} ON {$tableName} ({$columns})", __METHOD__); } } elseif ($wgDBtype == 'sqlite') { // SQLite $db->query("CREATE {$type} {$indexName} ON {$tableName} ({$columns})", __METHOD__); } else { // MySQL and default $db->query("ALTER TABLE {$tableName} ADD {$type} ({$columns})", __METHOD__); } self::reportProgress("done.\n", $reportTo); }