From: skodak Date: Sun, 1 Oct 2006 12:04:34 +0000 (+0000) Subject: Recent wiki table changes have problems on PostgreSQL 7.4 MDL-6724 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ea580cdfa642e6cb3c1e65cef9f183dff182d844;p=moodle.git Recent wiki table changes have problems on PostgreSQL 7.4 MDL-6724 --- diff --git a/mod/wiki/db/postgres7.php b/mod/wiki/db/postgres7.php index 5790cf3951..b0ca05be88 100644 --- a/mod/wiki/db/postgres7.php +++ b/mod/wiki/db/postgres7.php @@ -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;