78 foreach ( $this->tablesToClone as $tbl ) {
82 throw new RuntimeException(
"Cannot clone shared table $tbl." );
84 # Clean up from previous aborted run. So that table escaping
85 # works correctly across DB engines, we need to change the pre-
86 # fix back and forth so tableName() works right.
89 $oldTableName = $this->db->tableName( $tbl,
'raw' );
92 $newTableName = $this->db->tableName( $tbl,
'raw' );
96 if ( $this->dropCurrentTables
97 && !in_array( $this->db->getType(), [
'oracle' ] )
99 if ( $oldTableName === $newTableName ) {
101 throw new LogicException(
"Not dropping new table, as '$newTableName'"
102 .
" is name of both the old and the new table." );
104 $this->db->dropTable( $tbl, __METHOD__ );
105 wfDebug( __METHOD__ .
" dropping {$newTableName}\n" );
110 wfDebug( __METHOD__ .
" duplicating $oldTableName to $newTableName\n" );
111 $this->db->duplicateTableStructure(
120 public function destroy( $dropTables =
false ) {
123 foreach ( $this->tablesToClone as $tbl ) {
124 $this->db->dropTable( $tbl );
139 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
140 $lbFactory->setDomainPrefix( $prefix );
$wgDBprefix
Table name prefix.
$wgSharedDB
Shared database for multiple wikis.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
bool $useTemporaryTables
Whether to use temporary tables or not.
bool $dropCurrentTables
Should we DROP tables containing the new names?
cloneTableStructure()
Clone the table structure.
IMaintainableDatabase $db
static changePrefix( $prefix)
Change the table prefix on all open DB connections/.
string $newTablePrefix
Table prefix for cloning.
destroy( $dropTables=false)
Change the prefix back to the original.
array $tablesToClone
List of tables to be cloned.
useTemporaryTables( $u=true)
Set whether to use temporary tables or not.
__construct(IMaintainableDatabase $db, array $tablesToClone, $newTablePrefix, $oldTablePrefix='', $dropCurrentTables=true)
string $oldTablePrefix
Current table prefix.
Advanced database interface for IDatabase handles that include maintenance methods.