From 53cf39c97a712c9b0a890d60e3291f1e98f17b92 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 18 Oct 2010 18:26:11 -0700 Subject: [PATCH] strip column prefix lengths from key defs on pg --- lib/pgsqlschema.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/pgsqlschema.php b/lib/pgsqlschema.php index aa7f6733b0..599f7ffca2 100644 --- a/lib/pgsqlschema.php +++ b/lib/pgsqlschema.php @@ -409,7 +409,33 @@ class PgsqlSchema extends Schema $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; + } } -- 2.39.5