From 08e1fad13ff509a36ebc22b441da6e766f4954e4 Mon Sep 17 00:00:00 2001 From: patrickslee Date: Wed, 29 Mar 2006 05:16:59 +0000 Subject: [PATCH] Completed postgres binary upgrade block for wiki module --- mod/wiki/db/postgres7.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mod/wiki/db/postgres7.php b/mod/wiki/db/postgres7.php index 697dfb7fe5..be2c1f0bc0 100644 --- a/mod/wiki/db/postgres7.php +++ b/mod/wiki/db/postgres7.php @@ -127,10 +127,22 @@ function wiki_upgrade($oldversion) { if ($oldversion < 2006032900) { global $db; - $data = $db->GetAll("SELECT id,refs FROM {$CFG->prefix}wiki_pages"); + table_column("wiki_pages",'','content_base64','text'); + table_column("wiki_pages",'','refs_base64','text'); + $olddebug = $db->debug; + $db->debug = false; + $data = $db->GetAll("SELECT id,content,refs FROM {$CFG->prefix}wiki_pages"); foreach ($data as $d) { - $db->AutoExecute("{$CFG->prefix}wiki_pages", array('refs_base64' => base64_encode($d['refs'])), 'UPDATE', 'id = '.$d['id']); + $db->AutoExecute("{$CFG->prefix}wiki_pages", array('refs_base64' => base64_encode($d['refs']), 'content_base64' => base64_encode($d['content'])), 'UPDATE', 'id = '.$d['id']); } + $db->debug = $olddebug; + execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN content"); + execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN refs"); + table_column("wiki_pages",'','content','bytea'); + table_column("wiki_pages",'','refs','bytea'); + execute_sql("UPDATE {$CFG->prefix}wiki_pages SET refs = decode(refs_base64, 'base64'), content = decode(content_base64, 'base64')"); + execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN content_base64"); + execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN refs_base64"); } return true; -- 2.39.5