Hi experienced colleagues, I have this challenge with my drupal site which is still under development. Now i can not even log in to my site. Below is the message displayed to me

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'connect_health.trigger_assignments' doesn't exist: SELECT ta.aid, a.type, a.label FROM {trigger_assignments} ta LEFT JOIN {actions} a ON ta.aid = a.aid WHERE ta.hook = :hook ORDER BY ta.weight; Array ( [:hook] => node_view ) in trigger_get_assigned_actions() (line 169 of C:\wamp\www\ConnectHealth\modules\trigger\trigger.module).

Please help me out.


Make sure you've implemented hook_schema() to define the trigger_assignments table. Also, you should include an update hook using hook_update_N() to add the table if it doesn't exist already incase the module is enabled in some other Drupal site somewhere that will be receiving the updated module. The examples provided for both hooks should be enough to get you off the ground and running.

When I add a new table to a module that has already been deployed in the field, I like to use the following when defining my update hooks, for example:

function mymodule_update_7001() {
  $schema = mymodule_schema();
  if (!db_table_exists('my_new_table')) {
    db_create_table('my_new_table', $schema['my_new_table']);

If you've already enabled the module, but haven't added the table yet, using drush you can run drush updb to run all existing update hooks that haven't been added yet.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.