I have just tried to install salesforce module on my fresh D7 instance. and got this error,

DOException: SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'drupal_type' doesn't exist in table: CREATE TABLE {salesforce_object_map} ( `fieldmap` INT unsigned NOT NULL DEFAULT 0 COMMENT 'Fieldmap id', `oid` INT unsigned NOT NULL DEFAULT 0 COMMENT 'Specific Drupal object identifier (e.g. node id or comment id)', `sfid` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Salesforce object identifier (e.g. \"node\", \"comment\")', `drupal_entity` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'Drupal entity (e.g. \"node\", \"user\")', `drupal_bundle` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'Drupal bundle (e.g. \"page\", or vocabulary name)', PRIMARY KEY (`drupal_type`, `oid`), INDEX `sfid` (`sfid`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Drupal to Salesforce object mapping table'; Array ( ) in db_create_table() (line 2588 of /var/www/yogesh/drupal-7/includes/database/database.inc).

When I check for details in above error, it is saying 'Key column 'drupal_type' doesn't exist in table', so I check for hook_schema in D7 and this is like we are giving primary key 'primary key' => array('nid'),
And in salesforce api install file it is given like this
line no. 80 'primary key' => array('drupal_type', 'oid'),

When I change this to
line no. 80 'primary key' => array('oid'),

the error msg get solved.

Comments

EvanDonovan’s picture

Sounds like the drupal_type field has been removed in the schema for 7.x.

Unfortunately, the 6.x version has been getting a lot more attention recently, so you may run into other issues. Does your project require 7.x?

Thanks for testing!

yogeshchaugule8’s picture

Actually We are trying to import some sites from D6 to D7.
And one of our site includes the salesforce, because of which I was trying this module to install in D7

EvanDonovan’s picture

Title: DOException: SQLSTATE[42000]: Syntax error or access violation » Missing "drupal_type" column in {salesforce_object_map} for 7.x, but still in primary key (needs schema update)

@yogeshchaugule8: As far as I know, there is not an upgrade path between the 6.x and 7.x versions yet. (Plus, the 6.x version you are using may be a dev, in which case the date on it matters to what the schema is.)

Someone else might be able to provide more info though.

Can you provide a patch for the fix that you made to 7.x?

yogeshchaugule8’s picture

I dont know how to add a patch to module, but before adding patch we need to solve the other issues as well.

I have already added the line which solved that problem in above. adding again

before
'primary key' => array('drupal_type', 'oid'),

after
'primary key' => array('oid'),

while installing sub-module in salesforce I am getting this error.

DatabaseSchemaObjectExistsException: Table salesforce_prematch already exists. in DatabaseSchema->createTable() (line 630 of /var/www/drupal-7/includes/database/schema.inc).

I have not get any chance to see this in details.

yogeshchaugule8’s picture

DatabaseSchemaObjectExistsException: Table salesforce_prematch already exists. in DatabaseSchema->createTable() (line 630 of /var/www/drupal-7/includes/database/schema.inc).

This problem is related to this one
http://drupal.org/node/821684#comment-3210394
nicholasThompson is saying in his comment
"It seems hook_schema() now gets called in install and uninstall automatically"

If I am commenting hook_install then this problem is not comming.

/**
 * Implementation of hook_install().
 */
/*function sf_prematch_install() {
  drupal_install_schema('sf_prematch');
}*/
EvanDonovan’s picture

@yogeshchaugule8: The actual fix for this would be to check if the table exists first, and only call drupal_install_schema if it does not.

But you have combined two different problems into one issue. The "table already exists" should be a separate issue.

yogeshchaugule8’s picture

Thank you EvanDonovan,

I have created a new issues 'Table salesforce_prematch already exists'

cooperq’s picture

StatusFileSize
new601 bytes

I was also having this problem when installing Salesforce on a NEW copy of drupal 7 (no upgrade). I created a patch based on @yogeshchaugule8 suggestion of how to fix it. I reccomend this patch get rolled in immediately as at least for me, this bug was a blocker, making my whole site go down.

aaronbauman’s picture

Status: Active » Postponed
StatusFileSize
new800 bytes

a few things:

  • 'oid' alone is not sufficiently specific to serve as a primary key - a user, node, and order can all have the same numeric id.
  • a direct mapping from the exising 6.x schema implies that the key should become 'drupal_entity', 'drupal_bundle', 'oid'
  • however, depending on the outcome of #1018690: Remove the "drupal_type" column in {salesforce_object_map}, the key could become either 'fieldmap', 'oid', 'sfid' or simply 'oid', 'sfid'

Please feel free to use the attached stop-gap patch (updating the key to 'drupal_entity', 'drupal_bundle', 'oid'), but i'm going to postpone this on #1018690

aaronbauman’s picture

Priority: Critical » Normal

Seeing as how at least one other person ran into this issue (#1075724: Cannot enable module), it makes sense to roll patch from #9 is into 7.x-dev
This is done pending rollback based on #1018690.
http://drupalcode.org/project/salesforce.git/commit/ddb0407

Leaving as postponed on that issue.

EvanDonovan’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Priority: Normal » Major
Status: Postponed » Active

This issue will probably need to be re-titled, but I'm moving it up to 7.x-2.x now, to remind myself that I will need to consider this when designing the schema for that branch.

EvanDonovan’s picture

Status: Active » Fixed

Fixed in 7.x-2.x now - see salesforce_api.install for details. If you think the schema needs further discussion, please reopen.

Status: Fixed » Closed (fixed)

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