Hi, I'm trying the TW/Migrate combination for an import and am receiving the following error when I add a Content Set:

Could not analyze migrate_map_CC_Export (connection default)
Could not analyze migrate_msgs_CC_Export (connection default)

The tables are both present in tw_tables:
migrate_msgs_CC_Export default 0 migrate_msgs_CC_Export
migrate_map_CC_Export default 0 migrate_map_CC_Export

The name of the table/view I'm importing is CC_Export.

Ignoring the error (usually not a good idea) and performing a drush import gives this response:

chp-d617 515 $ drush migrate-import 1 --feedback="30 seconds"
The drush command hook naming conventions have changed; the function                    [error]
drush_migrate_migrate_import must be renamed to drush_migrate_import.  The old function
will be called, but this will be removed shortly.
Importing content set 'Basic import'                                                       [notice]
WD php: Table 'chp-new.migrate_map_CC_Export' doesn't exist                             [error]
query: SELECT cc_export.Email_Address AS Email_Address,
...
 FROM cc_export cc_export 
 LEFT JOIN migrate_map_CC_Export migrate_map_CC_Export ON cc_export.Email_Address =
migrate_map_CC_Export.sourceid
 LEFT JOIN migrate_msgs_CC_Export migrate_msgs_CC_Export ON cc_export.Email_Address =
migrate_msgs_CC_Export.sourceid
 WHERE (migrate_map_CC_Export.sourceid IS NULL OR migrate_map_CC_Export.needs_update =
1) AND (migrate_msgs_CC_Export.sourceid IS NULL)
    in
/Users/aangel/LocalDevelopment/htdocs/chp-d617/sites/all/modules/migrate/migrate.module
on line 719.

which is probably to be expected.

Could it have anything to do with this error in TW that I discovered last night?
Invisible Primary Key
http://drupal.org/node/869144

Move the question to the TW queue? I'm asking here first because Migrate depends on TW and it's probably best to know first what its trying to do when the error occurs.

Thanks,
-André

Comments

aangel’s picture

Aha, just thought to check the log and found:

BLOB/TEXT column 'sourceid' used in key specification without a key length query: CREATE TABLE migrate_msgs_CC_Export ( `mceid` INT unsigned NOT NULL auto_increment, `sourceid` LONGTEXT NOT NULL, `level` INT unsigned NOT NULL DEFAULT 1, `message` MEDIUMTEXT NOT NULL, PRIMARY KEY (mceid), INDEX sourceid (sourceid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /Users/aangel/LocalDevelopment/htdocs/chp-d617/includes/database.inc on line 550.

Tracing it back, it looks like Table Wizard imported my raw csv file and used LONGTEXT from the primary key. When creating the migrate_msgs_* table, Schema uses the same column type, which requires a key length be specified for the index.

Going back to the original table (CC_Export) and changing the LONGTEXT to VARCHAR resolved the problem.

I don't know why TW selected LONGTEXT for my primary key/first field but hopefully this helps someone else.

mikeryan’s picture

Project: Migrate » Table Wizard
Status: Active » Closed (works as designed)

The map table key is the same type as the source table key (since it has to hold the same values). When Table Wizard imports a file, it doesn't know what type each column should be, so it defaults to text fields for maximum generality. It also displays a message alerting you that it has done this:

%filename has been imported into new table %tablename. All fields have initially been defined as text, with no indexing - it is important to use your database management software to set appropriate data types for each field, and to define a single (unique, non-null) field as the primary key. After you have done this, reanalyze the table.