map the mysql-ish column types to ones postgres likes

This commit is contained in:
Brenda Wallace 2010-03-10 22:02:56 +13:00
parent 7398353c44
commit 75e2be3b71

View File

@ -216,6 +216,22 @@ class PgsqlSchema extends Schema
return true;
}
/**
* Translate the (mostly) mysql-ish column types into somethings more standard
* @param string column type
*
* @return string postgres happy column type
*/
private function _columnTypeTranslation($type) {
$map = array(
'datetime' => 'timestamp'
);
if(!empty($map[$type])) {
return $map[$type];
}
return $type;
}
/**
* Adds an index to a table.
*
@ -485,11 +501,12 @@ class PgsqlSchema extends Schema
private function _columnSql($cd)
{
$sql = "{$cd->name} ";
$type = $this->_columnTypeTranslation($cd->type);
var_dump($type);
if (!empty($cd->size)) {
$sql .= "{$cd->type}({$cd->size}) ";
$sql .= "{$type}({$cd->size}) ";
} else {
$sql .= "{$cd->type} ";
$sql .= "{$type} ";
}
if (!empty($cd->default)) {