[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gallery-devel
Subject:    [Gallery-devel] Patch to fix Core upgrades to 2.1 with postgresql DBs
From:       Sammy Spets <sammys+gallery () synerger ! com>
Date:       2006-03-28 20:04:14
Message-ID: 20060328210403.GA8295 () beaver ! synerger ! com
[Download RAW message or body]

Hi everyone,

I had a problem upgrading from G2.0.4 to G2.1. I'm using postgres and 
there was a query error because psql doesn't allow setting defaults when 
adding fields.

If you really want, I can send you the stack trace, but I believe the 
problem is self explanatory.

Patch file content is shown below and is attached.

-- <snip> --
diff -u -r1.20 schema.tpl
--- modules/core/classes/GalleryStorage/schema.tpl      20 Mar 2006 16:38:59 -0000      1.20
+++ modules/core/classes/GalleryStorage/schema.tpl      28 Mar 2006 04:15:24 -0000
@@ -809,7 +809,11 @@
 # A_GalleryAccessMap_1.0
 DROP INDEX DB_TABLE_PREFIXAccessMap_33666;
 
-ALTER TABLE DB_TABLE_PREFIXAccessMap ADD COLUMN DB_COLUMN_PREFIXuserOrGroupId INTEGER DEFAULT '0';
+ALTER TABLE DB_TABLE_PREFIXAccessMap ADD COLUMN DB_COLUMN_PREFIXuserOrGroupId INTEGER;
+
+ALTER TABLE DB_TABLE_PREFIXAccessMap ALTER COLUMN DB_COLUMN_PREFIXuserOrGroupId SET DEFAULT '0';
+
+UPDATE DB_TABLE_PREFIXAccessMap SET DB_COLUMN_PREFIXuserOrGroupId = '0';
 
 ALTER TABLE DB_TABLE_PREFIXAccessMap ALTER DB_COLUMN_PREFIXuserOrGroupId SET NOT NULL;
 
-- </snip> --

I tested it on my multisite setup with no problems for any of the sites.

Cheers,

-- 
Sammy Spets
Synerger Pty Ltd
http://www.synerger.com/


["schema.tpl.pgsql-fix.patch" (text/plain)]

Index: modules/core/classes/GalleryStorage/schema.tpl
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryStorage/schema.tpl,v
retrieving revision 1.20
diff -u -r1.20 schema.tpl
--- modules/core/classes/GalleryStorage/schema.tpl	20 Mar 2006 16:38:59 -0000	1.20
+++ modules/core/classes/GalleryStorage/schema.tpl	28 Mar 2006 04:20:00 -0000
@@ -809,7 +809,11 @@
 # A_GalleryAccessMap_1.0
 DROP INDEX DB_TABLE_PREFIXAccessMap_33666;
 
-ALTER TABLE DB_TABLE_PREFIXAccessMap ADD COLUMN DB_COLUMN_PREFIXuserOrGroupId INTEGER DEFAULT '0';
+ALTER TABLE DB_TABLE_PREFIXAccessMap ADD COLUMN DB_COLUMN_PREFIXuserOrGroupId INTEGER;
+
+ALTER TABLE DB_TABLE_PREFIXAccessMap ALTER COLUMN DB_COLUMN_PREFIXuserOrGroupId SET DEFAULT '0';
+
+UPDATE DB_TABLE_PREFIXAccessMap SET DB_COLUMN_PREFIXuserOrGroupId = '0';
 
 ALTER TABLE DB_TABLE_PREFIXAccessMap ALTER DB_COLUMN_PREFIXuserOrGroupId SET NOT NULL;
 

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic