PostgreSQL patch for donation.

eleybourn - November 9, 2007 - 01:12
Project:Donation
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

A quick patch to make donation work under postgresql

--- donation.install    2007-06-11 01:59:41.000000000 +1000
+++ d.x 2007-11-09 12:15:19.599635024 +1100
@@ -29,6 +29,23 @@
       ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");

       break;
+    case 'pgsql':
+      db_query("CREATE TABLE {donations} (
+        did           SERIAL            PRIMARY KEY,
+        status        INT               NOT NULL DEFAULT '1',
+        name          VARCHAR(128)      DEFAULT NULL,
+        mail          VARCHAR(128)      DEFAULT NULL,
+        timestamp     INT               NOT NULL DEFAULT '0',
+        amount        NUMERIC           DEFAULT NULL,
+        currency      VARCHAR(5)        DEFAULT 'USD',
+        uid           INT               DEFAULT NULL,
+        donor_name    VARCHAR(255)      DEFAULT NULL,
+        donor_url     VARCHAR(255)      DEFAULT NULL,
+        donor_memo    VARCHAR(255)      DEFAULT NULL,
+        paypal_txn_id VARCHAR(255)      DEFAULT NULL,
+        donor_comment VARCHAR(255)      DEFAULT NULL
+      ); ");
+
   }
}

@@ -45,6 +62,10 @@
     case 'mysqli':
       // Update the existing data to derive the user id from the email address
       $ret[] = update_sql("UPDATE {donations} d INNER JOIN {users} u USING(mail) SET d.uid = u.uid WHERE d.uid = 0");
-      return $ret;
+      break;
+    case 'pgsql':
+      $ret[] = update_sql(" UPDATE {donations} SET uid=(SELECT u.uid FROM {users} u where u.mail=mail) WHERE uid = 0;");
+      break;
   }
+  return ret;
}

 
 

Drupal is a registered trademark of Dries Buytaert.