}
}
+ /**
+ * Append an SQL statement to drop an index from a table.
+ * Note that in PostgreSQL, index names are DB-unique.
+ *
+ * @param array $statements
+ * @param string $table
+ * @param string $name
+ * @param array $def
+ */
+ function appendDropIndex(array &$statements, $table, $name)
+ {
+ $statements[] = "DROP INDEX $name";
+ }
+
/**
* Quote a db/table/column identifier if necessary.
*
*/
function quoteIdentifier($name)
{
- return '"' . $name . '"';
+ return $this->conn->quoteIdentifier($name);
}
function mapType($column)
$col['type'] = $this->mapType($col);
unset($col['size']);
}
+ if (!empty($tableDef['primary key'])) {
+ $tableDef['primary key'] = $this->filterKeyDef($tableDef['primary key']);
+ }
+ if (!empty($tableDef['unique keys'])) {
+ foreach ($tableDef['unique keys'] as $i => $def) {
+ $tableDef['unique keys'][$i] = $this->filterKeyDef($def);
+ }
+ }
return $tableDef;
}
+ /**
+ * Filter the given key/index definition to match features available
+ * in this database.
+ *
+ * @param array $def
+ * @return array
+ */
+ function filterKeyDef(array $def)
+ {
+ // PostgreSQL doesn't like prefix lengths specified on keys...?
+ foreach ($def as $i => $item)
+ {
+ if (is_array($item)) {
+ $def[$i] = $item[0];
+ }
+ }
+ return $def;
+ }
}