]> git.mjollnir.org Git - moodle.git/commitdiff
Recent wiki table changes have problems on PostgreSQL 7.4 MDL-6724
authorskodak <skodak>
Sun, 1 Oct 2006 12:04:34 +0000 (12:04 +0000)
committerskodak <skodak>
Sun, 1 Oct 2006 12:04:34 +0000 (12:04 +0000)
mod/wiki/db/postgres7.php

index 5790cf395182c8a80185a8a6391280de55961de1..b0ca05be881da6b27ec4602365972520e5415be1 100644 (file)
@@ -172,7 +172,8 @@ CREATE TABLE prefix_wiki_locks
     }
     
     if($oldversion < 2006092602) {
-           // This used to be a BYTEA type for no apparent reason, which caused various queries to fail. The new
+/*
+           // This used to be a BYTEA type for no apparent reason, which caused various queries to fail. The new
            // install.xml uses TEXT so I figure it's safe to change it in upgrade too. This one broke the links page...
            modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN refs DROP DEFAULT;");
            modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN refs TYPE TEXT USING ENCODE(refs,'escape');");
@@ -181,6 +182,18 @@ CREATE TABLE prefix_wiki_locks
            modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN content DROP DEFAULT;");
            modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN content TYPE TEXT USING ENCODE(content,'escape');");
            modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN content SET DEFAULT '';");
+*/
+            // following code should be compatible with both pg 8.x and 7.4
+            table_column('wiki_pages', '', 'tempcontent', 'TEXT', '', '', '', '');
+            execute_sql("UPDATE {$CFG->prefix}wiki_pages SET tempcontent = ENCODE(content,'escape')");
+            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN content");
+            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages RENAME COLUMN tempcontent TO content");
+            
+            table_column('wiki_pages', '', 'temprefs', 'TEXT', '', '', '', '');
+            execute_sql("UPDATE {$CFG->prefix}wiki_pages SET temprefs = ENCODE(refs,'escape')");
+            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN refs");
+            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages RENAME COLUMN temprefs TO refs");
+
     }
 
     return true;