can be longer than 64 characters and Migrate blows up.

I'm trying to migrate an ubercart configuration using commerce migrate ubercart and as it happens I have a prefix. When CMU runs, migrate generates a migrate map name that is longer than 64 characters. This is a limitation of MySQL, but if you're going to generate table names, you should generate them in such a way so that you don't exceed the known limitations of MySQL.

My suggestion would be to cache a lookup of some kind that maps the table name to a short table name that will always fit within the 64 character limit or hash the field name and use that for the table name.

I'll take a look and see if I can figure out a patch for this problem.

Best,

Dick Munroe

Comments

munroe_richard’s picture

This patch addresses the issue, but it may not be the final word since it works by discarding extra bits off the end of the table names that are too long.

Index: migrate/plugins/sources/sqlmap.inc
===================================================================
--- migrate/plugins/sources/sqlmap.inc  (revision 12422)
+++ migrate/plugins/sources/sqlmap.inc  (working copy)
@@ -71,14 +71,16 @@
 
   public function __construct($machine_name, array $source_key,
       array $destination_key, $connection_key = 'default', $options = array()) {
+    $this->connection = Database::getConnection('default', $connection_key);
+    $prefixLength = strlen($this->connection->tablePrefix()) ;
     if (isset($options['track_last_imported'])) {
       $this->trackLastImported = TRUE;
     }
     // Default generated table names, limited to 63 characters
     $this->mapTable = 'migrate_map_' . drupal_strtolower($machine_name);
-    $this->mapTable = drupal_substr($this->mapTable, 0, 63);
+    $this->mapTable = drupal_substr($this->mapTable, 0, 63 - $prefixLength);
     $this->messageTable = 'migrate_message_' . drupal_strtolower($machine_name);
-    $this->messageTable = drupal_substr($this->messageTable, 0, 63);
+    $this->messageTable = drupal_substr($this->messageTable, 0, 63 - $prefixLength);
     $this->sourceKey = $source_key;
     $this->destinationKey = $destination_key;
     $this->connection = Database::getConnection('default', $connection_key);
mikeryan’s picture

Title: Generated migrate map table names... » Overlong map/message table names with prefixes
Version: 7.x-2.5 » 7.x-2.x-dev

Better title - the issue is specific to environments using prefixes.

mikeryan’s picture

Status: Active » Fixed

Committed your fix, thanks.

As you are aware, there is the risk that by truncating the names collisions may be generated. However, I think it's up to the particular application to watch out for this - remember that the map and message table names are under your control via the first argument to the MigrateSQLMap constructor. Modules like commerice_migrate_ubercart which are generating lengthy migration machine names may benefit by passing abbreviations here.

Status: Fixed » Closed (fixed)

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