Permalink
Browse files

Completed postgres binary upgrade block for wiki module

  • Loading branch information...
1 parent a83f9d2 commit 08e1fad13ff509a36ebc22b441da6e766f4954e4 patrickslee committed Mar 29, 2006
Showing with 14 additions and 2 deletions.
  1. +14 −2 mod/wiki/db/postgres7.php
View
@@ -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;

0 comments on commit 08e1fad

Please sign in to comment.