Skip to content

Commit 64be2d7

Browse files
author
Till Brehm
committed
Implemented #5209 Add support for renaming empty databases
1 parent 38751c0 commit 64be2d7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

server/plugins-available/mysql_clientdb_plugin.inc.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ function db_update($event_name, $data) {
331331
$timestamp = time();
332332

333333
$tables = $link->query("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema='".$old_name."' AND TABLE_TYPE='BASE TABLE'");
334+
$tables_all = $link->query("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema='".$old_name."'");
334335
if ($tables->num_rows > 0) {
335336
while ($row = $tables->fetch_assoc()) {
336337
$tables_array[] = $row['TABLE_NAME'];
@@ -436,6 +437,11 @@ function db_update($event_name, $data) {
436437
}
437438
}
438439

440+
} elseif ($tables->num_rows == 0 && $tables_all->num_rows == 0) {
441+
//* Rename empty database by creating a new one and dropping the old database
442+
$this->db_insert($event_name, $data);
443+
$this->db_delete($event_name, $data);
444+
439445
} else { //* SELECT TABLE_NAME error
440446
$app->log('Unable to rename database '.$old_name.' to '.$new_name, LOGLEVEL_ERROR);
441447
}

0 commit comments

Comments
 (0)