From: Brenda Wallace Date: Wed, 10 Mar 2010 09:02:56 +0000 (+1300) Subject: map the mysql-ish column types to ones postgres likes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=75e2be3b71cc5b6114a10e1b5f1e0c9e3074af19;p=quix0rs-gnu-social.git map the mysql-ish column types to ones postgres likes --- diff --git a/lib/pgsqlschema.php b/lib/pgsqlschema.php index 8252419023..86ffbeb2a7 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)) {