Hello,

I've started to use textimage module with my PostgreSQL database and I found that installation is not working.
Here is the installation code you have:

      db_query('CREATE TABLE {textimage_preset} (
        pid INTEGER NOT NULL CHECK (presetid > 0),
        name VARCHAR(255) NOT NULL DEFAULT \'\',
        settings TEXT NOT NULL DEFAULT \'\'
        PRIMARY KEY (presetid));'
      );

Found problems:
1. presetid column doesn't exist.
2. there is no coma after the last field declaration.

Proposed improvements:
1. Use int_unsigned type defined by Drupal core instead of INTEGER with CHECK.
2. No need to set NOT NULL for PK column (it will be not null automatically).
3. Use " " to wrap the whole SQL statement to avoid masking (easier copy&paste into SQL admin).

Here is the proposed code which works correcctly in PostgreSQL:

    db_query("
      CREATE TABLE {textimage_preset} (
        pid int_unsigned,
        name VARCHAR(255) NOT NULL DEFAULT '',
        settings TEXT NOT NULL DEFAULT '',
        PRIMARY KEY (pid)
      )
    ");

Comments

deciphered’s picture

Status: Active » Closed (duplicate)