From 0d577cbf7a6ad49f6b2f0f79f0f324f6c2ce8bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Sun, 4 Nov 2007 15:00:21 +0000 Subject: [PATCH] #179143 by chx and agentrickard: unify update code for files, fixing postgresql bugs with it --- modules/system/system.install | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/modules/system/system.install b/modules/system/system.install index 2ddfffb4686..60d5046d739 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -4221,20 +4221,8 @@ function system_update_6022() { db_add_index($ret, 'upload', 'vid', array('vid')); // The nid column was renamed to uid. Use the old nid to find the node's uid. - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql('UPDATE {files} f JOIN {node} n ON f.uid = n.nid SET f.uid = n.uid'); - // Use the existing vid to find the nid. - $ret[] = update_sql('UPDATE {upload} u JOIN {node_revisions} r ON u.vid = r.vid SET u.nid = r.nid'); - break; - - case 'pgsql': - $ret[] = update_sql('UPDATE {files} AS f SET uid = n.uid FROM {node} n WHERE f.uid=n.nid'); - // Use the existing vid to find the nid. - $ret[] = update_sql('UPDATE {upload} AS u SET nid = r.nid FROM {node_revisions} r WHERE u.vid = r.vid'); - break; - } + update_sql('UPDATE {files} SET uid = (SELECT n.uid FROM {node} n WHERE {files}.uid = n.nid)'); + update_sql('UPDATE {upload} SET nid = (SELECT r.nid FROM {node_revisions} r WHERE {upload}.vid = r.vid)'); // Mark all existing files as FILE_STATUS_PERMANENT. $ret[] = update_sql('UPDATE {files} SET status = 1');