From 75e2be3b71cc5b6114a10e1b5f1e0c9e3074af19 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 10 Mar 2010 22:02:56 +1300 Subject: map the mysql-ish column types to ones postgres likes --- lib/pgsqlschema.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/pgsqlschema.php b/lib/pgsqlschema.php index 825241902..86ffbeb2a 100644 --- a/lib/pgsqlschema.php +++ b/lib/pgsqlschema.php @@ -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)) { -- cgit v1.2.3-54-g00ecf