drupal contemplate module with postgres

I’ve been working on setting up a Drupal instance for work and have, for the first time been using Postgres for the database instead of MySQL. I was installing the Content Template module and got errors when the module tried to create the tables by default. I think the problem is with the fact that the CREATE statements in contemplate.install use MySQL-only data types.  It seems that others have reported this problem as there is an issue on the Drupal site at http://drupal.org/node/172775 .

I was able to create working tables manually with the following syntax:

CREATE TABLE contemplate (
    type character(32) DEFAULT '' NOT NULL,
    teaser text NOT NULL,
    body text NOT NULL,   rss text NOT NULL,
    enclosure character(128) NOT NULL,
    flags integer DEFAULT 0 NOT NULL,
    PRIMARY KEY (type)
);CREATE TABLE contemplate_files (
    site character(255) NOT NULL,
    data bytea NOT NULL,
    UNIQUE (site)
);

I made a patch to contemplate.install that fixed this issue. download

Once I got past the table creation, the module still returned SQL errors when I tried to update the template for a CCK content type. This seemed to be due to a problem with the SQL syntax. I made a patch to contemplate.module that fixes this in Postgres. I don’t know if it ends up breaking MySQL in the process. download

Oh yeah. I’m using Drupal 5.5 with contemplate 5.x-1.8 and Postgres 8.1.9