diff --git a/core/model/Database.php b/core/model/Database.php index a4ee06694..9bf40e304 100755 --- a/core/model/Database.php +++ b/core/model/Database.php @@ -236,8 +236,9 @@ abstract class Database extends Object { $this->checkAndRepairTable($table); } - $this->requireField($table, "ID", "int(11) not null auto_increment"); - + //DB ABSTRACTION: we need to convert this to a db-specific version: + $this->requireField($table, 'ID', DB::getConn()->IdColumn()); + // Create custom fields if($fieldSchema) { foreach($fieldSchema as $fieldName => $fieldSpec) { diff --git a/core/model/MySQLDatabase.php b/core/model/MySQLDatabase.php index 756000eb4..912c94b74 100644 --- a/core/model/MySQLDatabase.php +++ b/core/model/MySQLDatabase.php @@ -573,6 +573,16 @@ class MySQLDatabase extends Database { return 'varchar(' . $values['precision'] . ') character set utf8 collate utf8_general_ci'; } + /** + * This returns the column which is the primary key for each table + * In Postgres, it is a SERIAL8, which is the equivalent of an auto_increment + * + * @return string + */ + function IdColumn(){ + return 'int(11) not null auto_increment'; + } + /** * Returns true if the given table is exists in the current database * NOTE: Experimental; introduced for db-abstraction and may changed before 2.4 is released.