Looking at #420026: migrate_save_content_set() should update map table as necessary, it occurs to me a lot of things would be easier if the map table column names were consistent (i.e., always 'sourceid' and 'destid'). Also, introducing the reasonable restriction that a given view could only be the source for one content set would eliminate the need for the mcsid column in map tables, and the need to include the destination type in the map and message table names. So, I'm going to proceed with this refactoring. The update hook should fix up any existing tables, but custom views involving these tables will be affected, so heads up...
Comments
Comment #1
mikeryanDone. If you update an existing installation, you will need to update any code or custom views referencing the map and/or message tables to reflect their new names (destination - e.g., 'node' or 'user' - removed from the table name) and the map table fields names (now just 'sourceid' and 'destid').
Comment #2
robertdouglass commentedThis must have been a precursor to this one? http://drupal.org/node/463830
Comment #3
mikeryanYes, my next priority for migrate module work (after the issue I'm about to open:-) will be to handle #463830: Support non-integer keys in sources and #420026: migrate_save_content_set() should update map table as necessary, those will be quite a bit easier with the refactoring.
Comment #5
frankcarey commentedjust a note: This update (6000) was timing out for me after 90 seconds. I had a quite a few content sets (10?) so that may be why, but still surprising.
Do the new map tables allow you to take advantage of views arguments to use the same view for multiple content sets?
i see you said "Also, introducing the reasonable restriction that a given view could only be the source for one content set would eliminate the need for the mcsid column in map tables, and the need to include the destination type in the map and message table names"
Comment #6
frankcarey commentedI created a new content set and It looks like the map and msg table names are now being created using the mscid ("migrate_map_27"), so that in my mind would mean that YES, one view could be used as the basis for multiple content sets. This differs however from what update 6000 seemed to do because my existing map tables are all in the format "migrate_map_myviewname".
Comment #7
frankcarey commentedI'm getting a couple errors after saving my new content set:
* Could not analyze migrate_map_27 (connection default)
* Could not analyze migrate_msgs_27 (connection default)
Probably because the tables aren't being created.
Comment #8
mikeryanYour old tables should have been renamed to the migrate_map_mcsid format, it sounds like the failed update you had left things in an inconsistent state. At the time of update 6000, Table Wizard didn't have a $skip_analysis argument to tw_add_tables(), so if your map and message tables were large that would have been a problem.
Is there any more information you can give to help identify whether there's a current bug here? I don't know of any existing issues with managing the map and message tables...
Comment #9
frankcarey commentedFor the new tables, I'm getting this error in my logs:
The query works if I re-run the query with INT for the type. Is it missing?
Comment #10
frankcarey commentedI think this is related to use of external tables only, because if i use a view based on a local table it seems to work fine. Looks like some lookup of the primary key's type is failing and not being passed in the query above?
Comment #11
frankcarey commentedTraced it back to the schema_mysql_inspect() call (aliased by a schema_invoke('inspect') call in migrate.module)
schema_mysql_inspect() looks up all the tables in the database. Since once the external tables are defined in hook_views_data() by tw as having a 'default' database, when the schema_mysql_inspect() get's called, it's not going to be one of the tables listed because it doesn't really exist in that database.
I'm thinking a small patch to this might check for presence of a period in the table name and then overwrite the table and database values and continue as normal.
Comment #12
frankcarey commentedOK, this is what i've got so far in migrate.module:
But,I think the problem now is that $tabledb is the actual db name, not the alias from settings.php, so we'll have to get that back... driving on.
Comment #13
mikeryanI cannot reproduce this in my environment using external tables. This looks funky:
The external tables should not be identified with the default database in hook_views_data() (specifically, _tw_generate_views_table_data()), they should have their true DB. I'm wondering if maybe your problems are related to #610128: Can't add external and internal tables' columns to the same view - I'm guessing you're running with your latest changes there. Can you try using the current CVS of Table Wizard and see if you still have problems with that?
Thanks.
Comment #14
frankcarey commentedYes, the problem was that i had some sort of hybrid code, and now the new functionality is showing up for me. RE #9 - #12: the patch in #661934: Allow migrate to handle external tables. is still needed to get external tables working (and the tw patch it depends on)
Comment #15
frankcarey commented