fix for pgsql database migration

This commit is contained in:
Robin Appelman 2012-05-30 23:55:27 +02:00
parent 8b4e16ec77
commit d98a0a1bb9
1 changed files with 3 additions and 0 deletions

View File

@ -410,6 +410,9 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common
} }
$db->loadModule('Datatype', null, true); $db->loadModule('Datatype', null, true);
$type = $db->datatype->getTypeDeclaration($field['definition']); $type = $db->datatype->getTypeDeclaration($field['definition']);
if($type=='SERIAL PRIMARY KEY'){//not correct when altering a table, since serials arent a real type
$type='INTEGER';//use integer instead
}
$query = "ALTER $field_name TYPE $type USING CAST($field_name AS $type)"; $query = "ALTER $field_name TYPE $type USING CAST($field_name AS $type)";
$result = $db->exec("ALTER TABLE $name $query"); $result = $db->exec("ALTER TABLE $name $query");
if (PEAR::isError($result)) { if (PEAR::isError($result)) {