diff --git a/ecrire/base/db_pg.php b/ecrire/base/db_pg.php
index 2fd88d4ecb80c0cb4f8614aae738e6aed4cef8f4..8dd975ed516b5124da1bbd52a65c81f6d10d7150 100644
--- a/ecrire/base/db_pg.php
+++ b/ecrire/base/db_pg.php
@@ -151,35 +151,37 @@ function spip_pg_alter_change($table, $arg, $serveur='')
 
 // http://doc.spip.org/@spip_pg_alter_add
 function spip_pg_alter_add($table, $arg, $serveur='') {
-	if (!preg_match('/^(INDEX|KEY|PRIMARY\s+KEY|)\s*`?(\w+)`?(.*)$/', $arg, $r))
-	  spip_log("drop $arg  incompris", 'pg');
-	else {
-	    if (!$r[1])
-	      return spip_pg_query("ALTER TABLE $table ADD " . $r[2] . ' ' . mysql2pg_type($r[3]),  $serveur);
-	    elseif ($r[1][0] = 'P')
-	      return spip_pg_query("ALTER TABLE $table ADD PRIMARY KEY " . $r[2], $serveur);
-	    else {
-		return spip_pg_query("CREATE INDEX " . $table . '_' . $r[2] . "ON $table",  $serveur);
-	    }
+	if (!preg_match('/^(INDEX|KEY|PRIMARY\s+KEY|)\s*(.*)$/', $arg, $r)) {
+		spip_log("alter add $arg  incompris", 'pg');
+		return NULL;
+	}
+	if (!$r[1]) {
+		preg_match('/`?(\w+)`?(.*)/',$r[2], $m);
+		return spip_pg_query("ALTER TABLE $table ADD " . $m[1] . ' ' . mysql2pg_type($m[2]),  $serveur);
+	} elseif ($r[1][0] == 'P') {
+		preg_match('/\(`?(\w+)`?\)/',$r[2], $m);
+		return spip_pg_query("ALTER TABLE $table ADD CONSTRAINT $table" .'_pkey PRIMARY KEY (' . $m[1] . ')', $serveur);
+	} else {
+		preg_match('/`?(\w+)`?\s*(\([^)]*\))/',$r[2], $m);
+		return spip_pg_query("CREATE INDEX " . $table . '_' . $m[1] . " ON $table " . str_replace("`","",$m[2]),  $serveur);
 	}
 }
 
 // http://doc.spip.org/@spip_pg_alter_drop
 function spip_pg_alter_drop($table, $arg, $serveur='') {
-	if (!preg_match('/^(INDEX|KEY|PRIMARY\s+KEY|)\s*`?(\w+)`?/', $arg, $r))
+	if (!preg_match('/^(INDEX|KEY|PRIMARY\s+KEY|)\s*`?(\w*)`?/', $arg, $r))
 	  spip_log("alter drop: $arg  incompris", 'pg');
 	else {
 	    if (!$r[1])
 	      return spip_pg_query("ALTER TABLE $table DROP " . $r[2],  $serveur);
-	    elseif ($r[1][0] = 'P')
-	      return spip_pg_query("ALTER TABLE $table DROP CONSTRAINT PRIMARY", $serveur);
+	    elseif ($r[1][0] == 'P')
+	      return spip_pg_query("ALTER TABLE $table DROP CONSTRAINT $table" . '_pkey', $serveur);
 	    else {
 		return spip_pg_query("DROP INDEX " . $table . '_' . $r[2],  $serveur);
 	    }
 	}
 }
 
-
 // http://doc.spip.org/@spip_pg_explain
 function spip_pg_explain($query, $serveur=''){
 	if (strpos($query, 'SELECT') !== 0) return array();
diff --git a/ecrire/base/upgrade.php b/ecrire/base/upgrade.php
index 81a1b504d243db49dc3e2d6133ca919def508d91..4136964fcd78b7ca975eba23a47eef7efd3b7243 100644
--- a/ecrire/base/upgrade.php
+++ b/ecrire/base/upgrade.php
@@ -104,13 +104,16 @@ function maj_while($version_installee, $version_cible)
 // http://doc.spip.org/@serie_alter
 function serie_alter($serie, $q = array()) {
 	$etape = intval(@$GLOBALS['meta']['upgrade_etape_'.$serie]);
-	foreach ($q as $i => $req) {
+	foreach ($q as $i => $r) {
 		if ($i >= $etape) {
-			$f = array_shift($req);
-			spip_log("maj $serie etape $i: $f ".join(',',$req),'maj');
-			if (function_exists($f)) {
-			  call_user_func_array($f, $req);
-			  ecrire_meta('upgrade_etape_'.$serie, $i+1);
+			if (is_array($r)
+			AND function_exists($f = array_shift($r))) {
+				spip_log("$serie/$i: $f " . join(',',$r),'maj');
+				call_user_func_array($f, $r);
+				ecrire_meta('upgrade_etape_'.$serie, $i+1);
+			} else {
+			  echo "maj $serie etape $i incorrecte";
+			  exit;
 			}
 		}
 	}
diff --git a/ecrire/maj/v019.php b/ecrire/maj/v019.php
index c11c080d08c9f9129c0e3ac7d423175a51bca884..9fc5c0f9c61fd3775caddfbadc4c94d786b0976e 100644
--- a/ecrire/maj/v019.php
+++ b/ecrire/maj/v019.php
@@ -378,7 +378,7 @@ function maj_1_952() {
 	if (!$ok) die('echec sur maj_1_952()'); 
 }
 
-$GLOBALS['maj'][1][952] = array('maj_1_952');
+$GLOBALS['maj'][1][952] = array(array('maj_1_952'));
 
 function maj_1_953()
 {
@@ -387,7 +387,7 @@ function maj_1_953()
 	creer_base_types_doc($tables_principales['spip_types_documents']);
 }
 
-$GLOBALS['maj'][1][953] = array('maj_1_953');
+$GLOBALS['maj'][1][953] = array(array('maj_1_953'));
 
 $GLOBALS['maj'][1][954] = array(