In #2609310: Add highwater/track_changes examples to beer migrations, adding track_changes to the beer_term migration does not work as expected (changed source data does not get reimported). I've recently used track_changes with XML and JSON feeds successfully, so I was a bit perplexed, but I figured it out - with a SQL source, if possible (and ignore_map is not set), the source query is joined directly with the map query, so any previously-imported rows are not retrieved from the database. For track_changes to work, all source rows must be retrieved and hashed to check for changes, so the track_changes setting needs to disable the map join.

Easy to fix, just needs a test...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeryan created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, track_changes-fix-0.patch, failed testing.

kekkis’s picture

Assigned: Unassigned » kekkis
FileSize
2.06 KB
728 bytes

Rerolling on top of 8.2.x

kekkis’s picture

Assigned: kekkis » Unassigned
svendecabooter’s picture

I can confirm the patch above works.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mvbaalen’s picture

Updated the patch #3 for version 8.5.1.

mikeryan’s picture

Status: Needs work » Needs review

Let's run this through the testbot just to be sure (then set back to Needs work for tests).

borisson_’s picture

Status: Needs review » Needs work

Back to needs work for those tests, per #10.

quietone’s picture

+++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
@@ -266,18 +266,18 @@ protected function initializeIterator() {
+      // 1. If the map is joinable, join it (unless track_changes is set). We will
+      //    want to accept all rows which are either not in the map, or marked in

Also, the comment is > 80 characters. And it would be better if the comment explicitly states what happens when track_changes is set instead of somewhat burying it in a phrase in parenthesis.

mpotter’s picture

Priority: Normal » Major

I ran into this problem today and I confirm that the patch in #9 fixes this. I am raising the priority here because this problem essentially breaks the D7 -> D8 migration when using track_changes to update changed content. Without this patch none of the changes to fields on the content type were detected as changes. So, before the patch I had:

drush mim my_articles
Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'my_articles'

But after the patch I got:

drush mim my_articles
Processed 13 items (0 created, 13 updated, 0 failed, 0 ignored) - done with 'my_articles'

As far as I can tell, this affects all D7-> D8 migrations that need to track changes for incremental migrations...only new content gets created.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lemuelsantos’s picture

Version: 8.6.x-dev » 8.6.2
FileSize
2.14 KB

Updated the patch #3 for version 8.6.2.

quietone’s picture

Testing on 8.6.x

jcisio’s picture

Version: 8.6.2 » 8.7.x-dev

@lemuelsantos I don't see any difference between your patch (#15) and the previous one (#9). Still needs test.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

botris’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
10.87 KB
10.57 KB

Attached a new version of #9 (15 is identical) with tests.

Status: Needs review » Needs work

The last submitted patch, 19: 2787185-19.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

botris’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Needs work » Needs review
FileSize
10.86 KB
713 bytes

Removing hierarchy from test, as is not relevant. And test against 8.7

botris’s picture

Version: 8.7.x-dev » 8.8.x-dev
mikelutz’s picture

Resetting Version to 8.8

botris’s picture

Adding missing comma for code style.

mikelutz’s picture

These tests look really good. I'm uploading a patch with just the test now, and I'm going to upload a tweak to the fix to improve readability shortly.

mikelutz’s picture

New fix. We have logic for determining joinability spread into the constructor, the iterator initialization and the dedicated mapJoinable() method. This moves all the joinability logic into the mapJoinable() method for clarity.

The last submitted patch, 25: 2787185-25.drupal.TEST-ONLY.patch, failed testing. View results

mikelutz’s picture

Assigned: mikelutz » Unassigned
botris’s picture

Status: Needs review » Reviewed & tested by the community

I've retest a migration with track_changes: true, without the patch changes in the source are ignored, with the patch changes in the source are picked up and migrations are updated.

mikelutz’s picture

Status: Reviewed & tested by the community » Needs review

Thanks, but because your code is in the patch, you aren't eligible to rtbc, and neither am I. We will need heddn or someone else to rtbc now.

BenStallings’s picture

Status: Needs review » Needs work
Issue tags: +MidCamp 2019

I was able to replicate the problem and the solution! The term whose details I modified updated when I ran `drush mim` a second time without the update flag.

However, the other two terms that I had not modified also updated, so I think a test somewhere in this code is giving false positives. Sorry!

botris’s picture

@BenStallings I'm unable to reproduce your findings. But if I understand correct, all your items get updated every time you run a migration if you have track_changes: true ?
Could you maybe provide more information on how to reproduce this?

BenStallings’s picture

Sorry to be unclear. Here is what I did:

  1. ran `drush mim beer_term` and 3 terms imported.
  2. In the database, edited the details of one term in the source table.
  3. ran `drush mim beer_term` a second time, and nothing updated (problem replicated).
  4. applied the patch
  5. ran `drush mim beer_term` a third time, and the output indicated that all three terms updated, instead of just the one that I had changed.

Thanks!

botris’s picture

Status: Needs work » Needs review

I've done everything again from scratch and I can't reproduce.
This is what I've done, fresh D8.8 install and added contrib modules migrate_tools and migrate_plus.

  1. Enabled migrate modules, core, contrib and example
  2. edit migrate_plus.migration.beer_term.yml, and add track_changes: true to source
  3. apply patch from #26
  4. run drush mim beer_term, result: 3 terms creates
  5. edit details column of 1st record in table migrate_example_beer_topic
  6. run drush mim beer_term, result: 1 term updated

Please note that if you edit the style column you will get a new term as that's the primairy key.

As far as I can tell this is good for "Needs review".

heddn’s picture

Status: Needs review » Reviewed & tested by the community

This looks good. Tests cover things. Mentally debated the vocab being created in the test module's config but it isn't that big of a deal. Onward.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed fc11a4f5c1 to 8.8.x and 2c7fde88e2 to 8.7.x. Thanks!

This is a nice thing to get fixed! Backported to 8.7.x because this is a major bug fix.

  • alexpott committed fc11a4f on 8.8.x
    Issue #2787185 by botris, mikelutz, kekkis, mikeryan, lemuelsantos,...

  • alexpott committed 2c7fde8 on 8.7.x
    Issue #2787185 by botris, mikelutz, kekkis, mikeryan, lemuelsantos,...

Status: Fixed » Closed (fixed)

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

xjm’s picture

Version: 8.8.x-dev » 8.7.x-dev
Issue tags: -needs backport to 8.7.x

Just to document here: We don't use "needs backport" tags for minor versions. Issues are backported (or not) according to release allowed changes policy. The branch field should be set to the earliest minor branch that is eligible for the fix based on this policy. Thanks!