I tried to get PostgreSQL support in this module, and I did some modifs in the files legal.install and legal.module
legal.install
Add a switch case for pgsql
case 'pgsql':
$query1 = db_query("CREATE TABLE {legal_accepted} (
legal_id serial,
uid int NOT NULL default '0',
tc_id int NOT NULL default '0',
accepted int NOT NULL default '0',
PRIMARY KEY (legal_id)
) ");
$query2 = db_query("CREATE TABLE {legal_conditions} (
tc_id serial,
conditions text NOT NULL,
date integer NOT NULL default '0',
extras text,
changes text,
PRIMARY KEY (tc_id)
) ");
----
In the file legal.module, I had to change some INSERT statemets, as I saw they tried to insert always NULL into the primary Keys
i don't know how this change would affect to MySQL, as I don't understand much how it worked.
These are the diff changes from 4.7.0 version
[root@outeiro legal]# diff legal.module legal.module.bkp
300c300
< db_query("INSERT INTO {legal_conditions} ( conditions, date, extras, changes) VALUES ( '%s', %d, '%s', '%s')", $form_values['conditions'], time(), serialize($form_values['extras']), $form_values['changes']);
---
> db_query("INSERT INTO {legal_conditions} (tc_id, conditions, date, extras, changes) VALUES (NULL, '%s', %d, '%s', '%s')", $form_values['conditions'], time(), serialize($form_values['extras']), $form_values['changes']);
623c623
< db_query("INSERT INTO {legal_accepted} ( uid, tc_id, accepted) VALUES ( '%d', '%d', '%d')", $uid, $tc_id, time());
---
> db_query("INSERT INTO {legal_accepted} (legal_id, uid, tc_id, accepted) VALUES (NULL, '%d', '%d', '%d')", $uid, $tc_id, time());
[root@outeiro legal]#
As you can see the change is two INSERT INTO lines, removing the attempt to insert NULL in the legal_id and tc_id fields, as they are serial (autoincrement)
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | legal.module_install_psql_rerolled.patch | 2.85 KB | pearcec |
| #2 | legal_pgsql.patch | 1.7 KB | vivek.puri |
Comments
Comment #1
robert castelo commentedThanks, will review this on next round of development and hopefully include it.
Comment #2
vivek.puri commentedI have attached a patch for PostgreSQL support.
Comment #3
melat0nin commentedHi there
How do I apply this patch? I'm anxious to get Legal working on my postgresql Drupal installation (5.7).
Cheers :)
Comment #4
robert castelo commentedhttp://drupal.org/patch/apply
Comment #5
melat0nin commentedI tried downloading Patch for Windows (I don't have Patch on my server) and applying it but I get lots of errors.
Can you send me the patched file directly? laurence dot diver at gmail dot com
If it's possible I would appreciate it greatly :)
Comment #6
robert castelo commentedI've decided to hold off on any Postgresql support until the Drupal 6 version is complete and there's a full set of tests for the module. That will then allow me to easily check that any changes required for Postgresql support don't break MySQL support, and make it easy for Postgresql users to participate in testing (I don't have Postgresql installed).
Comment #7
pearcec commentedRerolled a better patch. Includes both intalls and SQL.
Comment #8
pearcec commentedComment #9
scottgifford commentedJust tried this patch, and it worked perfectly for me. Thanks!
Comment #10
robert castelo commentedAdding minor fix to Legal 6.x.8.5 which should make it work with PostgreSQL.