OG Subgroups does not seem to install properly with Postgres as the database on the back end.

After installation it throws the following errors:

    * warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "og_ancestry" already exists in C:\cvs\realcme\drupaltest\node_development_instance3\includes\database.pgsql.inc on line 125.
    * user warning: query: CREATE TABLE og_ancestry ( gid int NOT NULL, parent int NOT NULL, PRIMARY KEY (gid, parent)); in C:\cvs\realcme\drupaltest\node_development_instance3\includes\database.pgsql.inc on line 144.
    * warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "og_subgroups" does not exist in C:\cvs\realcme\drupaltest\node_development_instance3\includes\database.pgsql.inc on line 125.
    * user warning: query: CREATE INDEX og_subgroups_gid_idx ON og_subgroups (gid); in C:\cvs\realcme\drupaltest\node_development_instance3\includes\database.pgsql.inc on line 144.
    * warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "og_subgroups" does not exist in C:\cvs\realcme\drupaltest\node_development_instance3\includes\database.pgsql.inc on line 125.
    * user warning: query: CREATE INDEX og_subgroups_parent_idx ON og_subgroups (parent); in C:\cvs\realcme\drupaltest\node_development_instance3\includes\database.pgsql.inc on line 144.

The following code is in og_subgroups.install:

function og_subgroups_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {og_subgroups} (
        gid int(11) NOT NULL,
        parent int(11) NOT NULL,
        PRIMARY KEY (gid, parent)
      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
    break;
    case 'pgsql':
      db_query("CREATE TABLE {og_ancestry} (
       gid int NOT NULL,
       parent int NOT NULL,
       PRIMARY KEY (gid, parent));");
      db_query("CREATE INDEX {og_subgroups}_gid_idx ON {og_subgroups} (gid);");
      db_query("CREATE INDEX {og_subgroups}_parent_idx ON {og_subgroups} (parent);");
      break;
  }
}

For Postgres, is there a reason that table og_ancestry is being created rather than table og_subgroups? (With OG 5.x-7.3 og_ancestry already exists and it creates a conflict.) Also, are the two indexes {og_subgroups}_gid_idx and {og_subgroups}_parent_idx needed since gid and parent are already designated as primary keys?

Thanks

Comments

ezra-g’s picture

Title: Installing OG Subgroups using Postgres » Postgress errors on install
Category: support » bug

Thanks for this report!

The postgres part of the install file needs some revision.

ezra-g’s picture

Priority: Critical » Normal
ezra-g’s picture

Priority: Normal » Critical
Peter.Farrow’s picture

This code seems to work with similar changes made to function og_subgroups_update_1()


case 'pgsql':
      db_query("CREATE TABLE {og_subgroups} (
       gid int NOT NULL,
       parent int NOT NULL,
       PRIMARY KEY (gid, parent)
	   );");
      break;


amitaibu’s picture

Thanks, i'll have time to fix it in a few days. (unless ezra you wanna do it, looks like changing og_ancestry with og_subgroups

amitaibu’s picture

Version: 5.x-4.0 » 5.x-4.x-dev
Priority: Critical » Normal
Status: Active » Fixed

I had a look, this issue is *already solved* in the 5.x4-.x version.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.