forked from GNUsocial/gnu-social
map the mysql-ish column types to ones postgres likes
This commit is contained in:
parent
7398353c44
commit
75e2be3b71
@ -216,6 +216,22 @@ class PgsqlSchema extends Schema
|
|||||||
return true;
|
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.
|
* Adds an index to a table.
|
||||||
*
|
*
|
||||||
@ -485,11 +501,12 @@ class PgsqlSchema extends Schema
|
|||||||
private function _columnSql($cd)
|
private function _columnSql($cd)
|
||||||
{
|
{
|
||||||
$sql = "{$cd->name} ";
|
$sql = "{$cd->name} ";
|
||||||
|
$type = $this->_columnTypeTranslation($cd->type);
|
||||||
|
var_dump($type);
|
||||||
if (!empty($cd->size)) {
|
if (!empty($cd->size)) {
|
||||||
$sql .= "{$cd->type}({$cd->size}) ";
|
$sql .= "{$type}({$cd->size}) ";
|
||||||
} else {
|
} else {
|
||||||
$sql .= "{$cd->type} ";
|
$sql .= "{$type} ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($cd->default)) {
|
if (!empty($cd->default)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user