[whups] PATCH: pgsql support for update_log_table.php

Jason M. Felice jfelice at cronosys.com
Thu Jul 10 13:24:36 PDT 2003


attached.

-- 
 Jason M. Felice
 Cronosys, LLC <http://www.cronosys.com/>
 216.221.4600 x302
-------------- next part --------------
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";


More information about the whups mailing list