}
}
+ /**
+ * Drop an index from an existing table
+ *
+ * @param $table String: Name of the table to modify
+ * @param $index String: Name of the old index
+ * @param $patch String: Path to the patch file
+ * @param $fullpath Boolean: Whether to treat $patch path as a relative or not
+ */
+ function dropIndex( $table, $index, $patch, $fullpath = false ) {
+ if ( $this->db->indexExists( $table, $index ) ) {
+ wfOut( "Dropping $index from table $table... " );
+ $this->applyPatch( $patch, $fullpath );
+ wfOut( "ok\n" );
+ } else {
+ wfOut( "...$index key doesn't exist.\n" );
+ }
+ }
+
/**
* Modify an existing field
*
array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
- array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
- array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
+ array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
+ array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
array( 'do_cl_fields_update' ),
array( 'do_collation_update' ),
array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
- array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
- array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
+ array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
+ array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
);
exit( 1 );
}
-function drop_index_if_exists( $table, $index, $patch, $fullpath = false ) {
- $dbw = wfGetDB( DB_MASTER );
- if ( $dbw->indexExists( $table, $index ) ) {
- wfOut( "Dropping $index from table $table... " );
- if ( $fullpath ) {
- $dbw->sourceFile( $patch );
- } else {
- $dbw->sourceFile( archive( $patch ) );
- }
- wfOut( "ok\n" );
- } else {
- wfOut( "...$index doesn't exist.\n" );
- }
-}
-
function archive( $name ) {
return DatabaseBase::patchPath( $name );
}