Hi, I've recently updated my site from D6 to D7.

When I enable the uc_affiliate2 module I get the following error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'admin_stagingst7x30.uc_affiliate2_user_commission' doesn't exist: SELECT * FROM {uc_affiliate2_user_commission} WHERE uid IN (:uids_0); Array ( [:uids_0] => 1 ) in uc_affiliate2_user_load() (line 382 of /home/projects/sooperthemesv3/staging-st-7x-30/sites/all/modules/uc_affiliate2/uc_affiliate2.module).

Also, when I go to update.php there are not updates listed to be run for uc_affiliate2, and the user_commision table does not exist in my database. This error causes a sitewide failure of my website.

CommentFileSizeAuthor
#8 1376108-missing-table.patch593 bytesdgtlmoon

Comments

nohup’s picture

Status: Active » Postponed (maintainer needs more info)

Did you update to the latest version of uc_affiliate2 6.x before updating from 6.x to 7.x? uc_affiliate2_user_commission should be there in 6.x.

AlanT’s picture

Version: 7.x-1.1 » 7.x-1.2

I'm running into a similar issue. I've upgraded everything else from D6 to D7, but when I activate the UC_Affiliate2 module, I get "The website encountered an unexpected error. Please try again later. " messages, preventing the site from being seen.

When I deactivate the module by going into the database, I can then see the watchdog log, which says:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'upgrade.uc_affiliate2_user_commission' doesn't exist: SELECT * FROM {uc_affiliate2_user_commission} WHERE uid IN (:uids_0); Array ( [:uids_0] => 1 ) in uc_affiliate2_user_load() (line 382 of D:\public_html\upgrade\sites\all\modules\uc_affiliate2\uc_affiliate2.module).

Before upgrading, the D6 version of all modules were up-to-date (Ubercart Affiliate v2 6.x-2.6), and I do not have uc_affiliate2_user_commission table in the database. I have uc_affiliate2_user and uc_affiliate2_commission tables, though.

In looking through the schema of all D6 versions of this module (including 6.x-2.x-dev and 6.x-3.x-dev) I see no such table as claimed above.

I've run the update.php script even though no updates where indicated. (after re-enabling the module) Same result.

At this point, this is the only thing preventing me from upgrading my site.

Thanks.

davidarthur’s picture

I can confirm this issue is present on our upgrade, the table never exists in the d6 version and is not created in the upgrade process.

duckzland’s picture

I had to make a hook_update_N to force create the missing table, This shouldn't be considered as a proper fix. just a quick hack to make things work.

/**
 * Creating missing table due to importing from Drupal 6
 */
function uc_affiliate2_update_7001() {
  if (!db_table_exists('uc_affiliate2_user_commission')) {
    $schema = uc_affiliate2_schema();
    db_create_table('uc_affiliate2_user_commission', $schema['uc_affiliate2_user_commission']);
  }
}

note: append the code to uc_affiliate2.install file

interestingaftermath’s picture

Thanks #4! Worked perfectly.

dgtlmoon’s picture

Status: Postponed (maintainer needs more info) » Active

Worked for me too, looks like the original update hooks for the D7 version dont deal with this at all

dgtlmoon’s picture

Title: how to update from 6 to 7 » Updating from 6 to 7 doesn't add tables
Version: 7.x-1.2 » 7.x-1.x-dev
dgtlmoon’s picture

StatusFileSize
new593 bytes

not sure if this is the right approach, but here's a patch anyway