mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8286 from wilr/patches/mysql-create-table-issue
Check database has table before altering.
This commit is contained in:
commit
d2b646cc13
@ -4,6 +4,7 @@ namespace SilverStripe\ORM\Connect;
|
|||||||
|
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
|
use LogicException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents schema management object for MySQL
|
* Represents schema management object for MySQL
|
||||||
@ -139,9 +140,21 @@ class MySQLSchemaManager extends DBSchemaManager
|
|||||||
return $info && strtoupper($info['Table_type']) == 'VIEW';
|
return $info && strtoupper($info['Table_type']) == 'VIEW';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renames a table
|
||||||
|
*
|
||||||
|
* @param string $oldTableName
|
||||||
|
* @param string $newTableName
|
||||||
|
* @throws LogicException
|
||||||
|
* @return Query
|
||||||
|
*/
|
||||||
public function renameTable($oldTableName, $newTableName)
|
public function renameTable($oldTableName, $newTableName)
|
||||||
{
|
{
|
||||||
$this->query("ALTER TABLE \"$oldTableName\" RENAME \"$newTableName\"");
|
if (!$this->hasTable($oldTableName)) {
|
||||||
|
throw new LogicException('Table '. $oldTableName . ' does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->query("ALTER TABLE \"$oldTableName\" RENAME \"$newTableName\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkAndRepairTable($tableName)
|
public function checkAndRepairTable($tableName)
|
||||||
|
Loading…
Reference in New Issue
Block a user