running drush from inside of my /home/duran/www/drupal directory, works when I "drush dl views".
and when I do "drush enable views", it actually works. (views is availiable), but I get a REALLY REALLY long set of SQL errors.

duran@studentgroups:~/www/drupal$ drush enable views
The following modules will be enabled: views
Do you really want to continue? (y/n): y
Views was enabled successfully.                                                                                           [ok]
user warning: Table 'drupal.cache_views' doesn't exist                                                     [error]
query: DELETE FROM cache_views in /home/duran/www/drupal/includes/cache.inc on line 172.
user warning: Table 'drupal.views_view' doesn't exist                                                      [error]
query: SELECT DISTINCT v.* FROM views_view v in /home/duran/www/drupal/sites/all/modules/views/includes/view.inc on line
1249.
user warning: Table 'drupal.cache_views' doesn't exist                                                     [error]
query: SELECT data, created, headers, expire, serialized FROM cache_views WHERE cid = 'views_default_views:en'
in /home/duran/www/drupal/includes/cache.inc on line 26.
user warning: Table 'drupal.cache_views' doesn't exist                                                     [error]
query: UPDATE cache_views SET data =
'a:6:{s:15:\"comments_recent\";O:4:\"view\":22:{s:8:\"db_table\";s:10:\"views_view\";s:10:\"base_table\";s:8:\"comments\";s:5:\"built\";b:0;s:8:\"executed\";b:0;s:4:\"args\";a:0:{}s:10:\"build_info\";a:0:{}s:8:\"use_ajax\";b:0;s:5:\"pager\";a:5:{s:9:\"use_pager\";b:0;s:14:\"items_per_page\";i:10;s:7:\"element\";i:0;s:6:\"offset\";i:0;s:12:\"current_page\";i:0;}s:17:\"attachment_before\";s:0:\"\";s:16:\"attachment_after\";s:0:\"\";s:12:\"exposed_data\";a:0:{}s:13:\"exposed_input\";a:0:{}s:8:\"old_view\";a:0:{}s:3:\"vid\";s:0:\"\";s:4:\"name\";s:15:\"comments_recent\";s:11:\"description\";s:162:\"Contains
a block and a page to list recent comments; the block will automatically link to the page, which displays the comment body
as well as a link to the

I've truncated this... it goes on for a long time, hundreds of lines...

As I said, it does the job, it enables views... but it spits out a lot of ERRORS, that are listed, as [error]

All latest versions of drupal, views and drush
drupal 6.12
views 6.x-2.5

Running on UBUNTU 9.04 server
Thanks.

Comments

pobster’s picture

I don't think this problem is specific to Views, I seem to get it on several modules and I'm using the most current dev version as well...? The issue appears to be that the install hook isn't being called any more? ...Or perhaps the install_schema??? How to tell?

Am using Leopard with MAMP and a self compiled apache environment on a Leopard dev box.

Pobster

ethanw’s picture

I am getting this error as well, only views is not installing correctly.

Looking into the views.install file, it looks like the cache_views schema is being loaded differently from the other table schemas:

 $schema['cache_views'] = drupal_get_schema_unprocessed('system', 'cache'); 

Could this be the source of the issue?

joachim’s picture

I got errors with date module:

$ drush enable date
The following modules will be enabled: date, date_api, date_timezone
Do you really want to continue? (y/n): y
Date was enabled successfully.                                       [ok]
Date API was enabled successfully.                                   [ok]
Date Timezone was enabled successfully.                              [ok]
user warning: Table 'drupal-gtf.date_format_types'         [error]
doesn't exist
query: SELECT dft.type, dft.title, dft.locked FROM date_format_types
dft ORDER BY dft.title in
/home/gtf/public_html/sites/all/modules/date/date_api.module on line
1963.
user warning: Table 'drupal-gtf.date_format_types'         [error]
doesn't exist
query: SELECT dft.type, dft.title, dft.locked FROM date_format_types
dft ORDER BY dft.title in
/home/gtf/public_html/sites/all/modules/date/date_api.module on line
1963.
An error occurred at function : drush_pm_enable                          [error]

Is this related?

pobster’s picture

Yes it is, as I mentioned in my post - this isn't specific for Views, it happens with most modules I enable through Drush... Their install hooks are simply ignored hence the tables not being found afterwards.

Pobster

hefox’s picture

Content (cck) is another module where this happens. The tables that had issues appeared to both be _cache tables, not sure if that's relevant.

hefox’s picture

Not sure if it's relavent but I realized the two modules that had issues are doubles; ie they exist under 2 files, in this case sites/all/modules and modules/acquia; didn't realize the were in the later.

David Stosik’s picture

Version: All-Versions-2.0 »

Same problem here, on Views.
I get the message telling Views was successfully installed, then a lot of SQL errors telling that many tables don't exist (at least cache_views and views_view).
I have only one instance of my code (as opposed to hefox).
When I check in my database, the tables are here so maybe some hooks are called in a wrong order?

I experienced the same problem with HEAD.

David Stosik’s picture

Component: Installation » Code
Priority: Normal » Critical

Just found a possible reason.
Check drush/commands/pm/pm.drush.inc file.

It first calls module_enable($modules), then, later, drupal_execute('system_modules', $form_state); (lines 242 to 270).

Actually, module_enable does not install a module, thus, does not run its hook_install.

By the way, running drupal_execute('system_modules', $form_state); clears a lot of cache, invokes a lot of hooks, and, among these hooks, are those of Views (or whatever module you just enabled), which won't find its tables (cache_views, views_view, ...).

Just commenting the line 270 drupal_execute('system_modules', $form_state); removes the errors, but does not install the module at all: the tables are not created.

I suggest to use the function drupal_install_modules($modules) to install those modules that were not installed before...

jonhattan’s picture

Status: Active » Needs work

It worked for me by changing `module_enable($modules)` by

require_once DRUPAL_ROOT . '/includes/install.inc';
drupal_install_modules($modules);

as suggested by David Stosik :).

David, do you wanna roll a patch?

jonhattan’s picture

A side note: is enough to do `require_once '/includes/install.inc';`(whithout DRUPAL_ROOT) as drush has set the working directory already to the drupal root. I think whithout DRUPAL_ROOT is the preferred way.

David Stosik’s picture

Assigned: Unassigned » David Stosik
Status: Needs work » Needs review
StatusFileSize
new954 bytes

Here it is.

I did a few testing, and it seemed OK:
I tried to enable a module, then disable it, the enable it again, then disable it, then uninstall it, and I also tried to install a module which has uninstalled dependency, and these tests worked.

Regards,
David

jonhattan’s picture

Status: Needs review » Reviewed & tested by the community

reviewed :)

jonhattan’s picture

Title: "drush enable views" works, but spits out a lot of SQL errors. » `drush enable` not running hook_install in modules enabled for the first time
q0rban’s picture

Me too/subscribe.

dave reid’s picture

Marked #572594: Error installing xmlsitemap on empty site as a duplicate of this issue. Also subscribing. Kind of a bad bug...

moshe weitzman’s picture

Assigned: David Stosik » owen barton

@Owen - could you take a look? AT least lets get this right for dt5/d6 and then tackle d7 since it needs significant work for pm commands.

kdes’s picture

@David

thanks for the patch. had the same issue while installing xmlsitemaps and its now fixed with ur patch.

john morahan’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.54 KB

Works well with D6, but in D5 drupal_install_modules() only installs new modules, ignoring any that were installed previously and disabled.

moshe weitzman’s picture

Status: Needs review » Fixed

Committed. Thanks.

Would be terrific if someone could refactor the D7 code for enable/disable/uninstall to make sure we take advantage of the new graph.inc which assures that module operations happen in dependency order.

Status: Fixed » Closed (fixed)

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