1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 02:04:35 +02:00
This commit is contained in:
Ryan Cramer
2025-01-05 10:54:17 -05:00
parent 00a6baaac9
commit bd5200dfb2
2 changed files with 9 additions and 4 deletions

View File

@@ -388,12 +388,14 @@ class Fields extends WireSaveableItems {
// even if only the case has changed.
$schema = $item->type->getDatabaseSchema($item);
if(!empty($schema)) {
foreach(array($table, "tmp_$table") as $t) {
list(,$tmpTable) = explode(Field::tablePrefix, $table, 2);
$tmpTable = "tempf_$tmpTable";
foreach(array($table, $tmpTable) as $t) {
if(!$database->tableExists($t)) continue;
throw new WireException("Cannot rename to '$item->name' because table `$table` already exists");
}
$database->exec("RENAME TABLE `$prevTable` TO `tmp_$table`"); // QA
$database->exec("RENAME TABLE `tmp_$table` TO `$table`"); // QA
$database->exec("RENAME TABLE `$prevTable` TO `$tmpTable`"); // QA
$database->exec("RENAME TABLE `$tmpTable` TO `$table`"); // QA
}
$item->prevTable = '';
}