dbtng_migrator will fail if there are any modules installed that use hook_schema_alter to add fields to another module's tables. The provided patch calls hook_schema_alter prior to creating db tables to rectify this.

Comments

josh waihi’s picture

Status: Needs review » Needs work

Whats the point of these lines?

@@ -61,7 +64,7 @@ function dbtng_migrator_batch_migrate_table($origin, $destination, &$context) {
       if (!is_array($schema)) {
         continue;
       }
-      foreach ($schema as $table => $info) { 
+      foreach ($schema as $table => $info) {
         $tables[] = $table;
       }
     }
@@ -108,8 +111,8 @@ function dbtng_migrator_batch_migrate_table($origin, $destination, &$context) {
       db_set_active($destination);
       $insert = db_insert($table)->fields(array_keys($schema['fields']));
       foreach ($rows as $row) {
-         $insert->values((array) $row); 
-      } 
+         $insert->values((array) $row);
+      }
       $insert->execute();
       $count += $limit;
     }

Why rename the variable to altered schema? could it just use the $schema variable?

greg.1.anderson’s picture

Status: Needs work » Needs review
StatusFileSize
new1.58 KB

Sorry about those "junk" lines; I am using a new nifty editor that is configured to automatically fix up any whitespace in the file that does not conform to Drupal coding conventions. It automatically converts tabs into spaces, and removes trailing whitespace from the ends of all lines. So, those no-difference-diff lines are showing where spurious trailing whitespace was removed.

Regarding $altered_schema, the intent was to skip creation of any table added to the schema by hook_schema_alter. Skipping this step causes the code to blow up, because the same table name is added to multiple schemas by some alter hooks, whereas there is no apparent problem with just skipping these tables.

Attached is a new patch that is functionally equivalent to #0, but is perhaps more expressive in its intention vis-a-vis hook_schema_alter.

josh waihi’s picture

Status: Needs review » Needs work

Cool. Couple of spelling mistakes e.g:

foreach ($original_schmea_table_list as $name) {

If you would be so kind as to explain in comments, why this process is needed. I'll be happy to commit it. Cheers.

greg.1.anderson’s picture

Status: Needs work » Needs review
StatusFileSize
new2.1 KB

Here is another pass that cleans up #2, but makes no functional changes.

josh waihi’s picture

Status: Needs review » Fixed

Patch commited to 7.x-1.x. Fix will appear in 7.x-1.1 release. Thanks!

Status: Fixed » Closed (fixed)

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