diff --git a/wire/core/Fields.php b/wire/core/Fields.php index 8efd9b38..5281507f 100644 --- a/wire/core/Fields.php +++ b/wire/core/Fields.php @@ -337,6 +337,10 @@ 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) { + 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 } @@ -1488,4 +1492,3 @@ class Fields extends WireSaveableItems { } } -