Can't generate 'create view' sql
yaoweizhen - April 28, 2009 - 16:52
| Project: | Backup and Migrate |
| Version: | 6.x-1.2 |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (to be ported) |
Description
There are view tables in my db. I checked generated sql file. No view creation sql statement before INSERT, so it always stopped at INSERT statement.

#1
Backup and migrate doesn't support MySQL views. Are there any Drupal modules that use them? Drupal is supposed to work with MySQL 4.1 so this should not be an issue with Drupal data, but if there are any contributed modules using them then I'll have to either support views or warn the user about not supporting them.
If you are backup up data from tools other than Drupal you would be safest to use a more complete tool like phpMyAdmin.
#2
I used this contrib module http://drupal.org/project/uc_views
I have created issue for this module http://drupal.org/node/448038
#3
Since many of the uc_views users are reporting this problem, I have created a patch for backup_migrate that allows db views to be backed up and restored.
the patch is made against the head branch.
hope you can use it.
By the way I noticed that you pass
$exclude_tablesand$nodata_tablesas parameters for_backup_migrate_dump_tablesand_backup_migrate_get_dump_sqlbut you don't seem to use the values since they are overwritten within the functions. Therefor I have avoided changing the signature of those functions, even though I have a$exclude_viewsequivalent to$exclude_tables.#4
And the patch attachement :-S
#5
Thanks for the patch. I'll review and port this as soon as possible. I may not add it to the 1.x branch as I'm trying to make that branch obsolete and am approaching a stable release for the 2.x branch.
#6
Today I had the chance to try out my patch in an installation without db-views and I realized that I am instantiating the default values of the lists containing the views and the view names wrong.
So rather than setting
$out = "";it really should be
$out = array();in both
function _backup_migrate_get_views()$out = "";
...
and
function _backup_migrate_get_view_names()$out = "";
...
Sorry for not testing properly the first time.
#7
I LOVE this module. It has saved my behind more than once.
I ran into this problem recently where a view table is not created. If you use ubercart at all, I think you will run into this issue.
The patch doesn't seem to work it all fails.
A
#8
How does the patch fail?