PATCH: pgsql support for update_log_table.php

"Jason M. Felice" <[email protected]>
Newsgroups gmane.comp.horde.whups
Message-ID <[email protected]>
attached.

-- 
 Jason M. Felice
 Cronosys, LLC <http://www.cronosys.com/>
 216.221.4600 x302


-- 
Whups mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
whups-update_log_table.php-pgsql.patch (text/plain, 1.7 KB)
Index: whups/scripts/update_logs_table.php
===================================================================
RCS file: /repository/whups/scripts/update_logs_table.php,v
retrieving revision 1.1
diff -u -u -r1.1 update_logs_table.php
--- whups/scripts/update_logs_table.php	25 Jun 2003 21:08:02 -0000	1.1
+++ whups/scripts/update_logs_table.php	10 Jul 2003 20:16:37 -0000
@@ -31,14 +31,28 @@
 $output = '';
 
 // Add new fields to whups_logs table
-$sql = "ALTER TABLE whups_logs ADD COLUMN type_id_to INT NOT NULL DEFAULT 0";
+if ($db->phptype == 'pgsql') {
+    $sql = "ALTER TABLE whups_logs ADD COLUMN type_id_to INT;
+        UPDATE whups_logs SET type_id_to = 0;
+        ALTER TABLE whups_logs ALTER COLUMN type_id_to SET NOT NULL;
+        ALTER TABLE whups_logs ALTER COLUMN type_id_to SET DEFAULT 0";
+} else {
+    $sql = "ALTER TABLE whups_logs ADD COLUMN type_id_to INT NOT NULL DEFAULT 0";
+}
 $result = $db->query($sql);
 if (is_a($result, 'PEAR_Error')) {
     $output .= "Could not add new column to table whups_logs.\n";
     $output .= $result->toString() . "\n\n";
 }
 
-$sql = "ALTER TABLE whups_logs ADD COLUMN module_id_to INT NOT NULL DEFAULT 0";
+if ($db->phptype == 'pgsql') {
+    $sql = "ALTER TABLE whups_logs ADD COLUMN module_id_to INT;
+        UPDATE whups_logs SET module_id_to = 0;
+        ALTER TABLE whups_logs ALTER COLUMN module_id_to SET NOT NULL;
+        ALTER TABLE whups_logs ALTER COLUMN module_id_to SET DEFAULT 0";
+} else {
+    $sql = "ALTER TABLE whups_logs ADD COLUMN module_id_to INT NOT NULL DEFAULT 0";
+}
 $result = $db->query($sql);
 if (is_a($result, 'PEAR_Error')) {
     $output .= "Could not add new column to table whups_logs.\n";
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.