From: Brion Vibber Date: Tue, 19 Oct 2010 01:26:11 +0000 (-0700) Subject: strip column prefix lengths from key defs on pg X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=53cf39c97a712c9b0a890d60e3291f1e98f17b92;p=quix0rs-gnu-social.git strip column prefix lengths from key defs on pg --- 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; + } }