Follow-up to #2687843: Add back incremental migrations through the UI

Problem/Motivation

Follow-up to #2683421: Remove incremental and rollback options from the UI (and add them back when they are more stable) which removes both the rollback and incremental options since they were untested and had several significant bugs. Unlike the incremental migration feature, rollback can probably be considered an additional feature and not necessarily block a stable Migrate UI.

Proposed resolution

Add back rollback migration support to the UI, with test coverage.

Only roll back content migrations, not configuration. This is because

  1. It is hard to roll back configuration reliably, since it can also be changed in other ways.
  2. It may be more useful to use the regular configuration management, after an initial migration, than to update, roll back, and re-run the configuration migrations.

Use the phrase 'incremental upgrade' instead of 'Rerun' as shown in the now dated screenshot. See #32

Check for NULL in core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php. This fixes a bug that was exposed by the new test coverage.

Add a link to Upgrade using web browser and update that page to describe the new option. Suggested text:

If an upgrade was not done then the Upgrade page provides information about the preparation steps that should be done before continuing with the upgrade. However, if an upgrade was done then you are asked if you want to import new configuration and content or to rollback the upgrade. If you continue, for any of these situations, you are then asked to define the source site.

Remaining tasks

  • Implement the new, reduced scope: only roll back content migrations.
  • Update the documentation in the handbook,

User interface changes

Before

After
Default is incremental

Selecting the Rollback


Druing rollback complete

Rollback complete

API changes

Depends on the solution.

Data model changes

None

CommentFileSizeAuthor
#200 2687849-200.patch15.38 KB_utsavsharma
#199 reroll_diff_190-199.txt18.18 KBsahil.goyal
#199 2687849-199.patch32.54 KBsahil.goyal
#191 interdiff-190.txt559 bytesKapilV
#190 2687849-190.patch32.29 KBKapilV
#189 2687849-189.patch15.44 KBKapilV
#187 2687849-187.patch32.29 KBquietone
#187 interdiff-186-187.txt10.5 KBquietone
#186 2687849-186.patch31.38 KBquietone
#186 interdiff-185-186.txt6.64 KBquietone
#185 2687849-185.patch29.16 KBquietone
#185 diff-170-185.txt922 bytesquietone
#170 2687849-170.patch29.21 KBquietone
#170 interdiff-168-170.txt1.28 KBquietone
#168 2687849-168.patch29.07 KBquietone
#168 diff-159-168.txt1.97 KBquietone
#162 interdiff.159-162.txt1.64 KBabhisekmazumdar
#162 2687849-162.patch30.41 KBabhisekmazumdar
#159 diff_157_159.txt7.77 KBadityasingh
#159 2687849-159.patch29.19 KBadityasingh
#157 2687849-157.patch30.14 KBquietone
#157 interdiff-151-157.txt978 bytesquietone
#151 2687849-151.patch30.17 KBquietone
#151 interdiff-149-151.txt2.9 KBquietone
#149 Screenshot_2021-01-08 Upgrade dev0-web(1).png29.82 KBquietone
#149 2687849-149.patch31.78 KBquietone
#149 interdiff-147-149.txt1.83 KBquietone
#147 Screenshot_2021-01-08 Upgrade dev0-web.png28.54 KBquietone
#147 2687849-147.patch31.5 KBquietone
#147 interdiff-144-147.txt12.71 KBquietone
#144 2687849-144.patch29.2 KBquietone
#144 interdff-141-144.txt3.75 KBquietone
#142 Screenshot_2020-12-16 Upgrade The Site Name.png36.29 KBquietone
#141 2687849-141.patch29.24 KBquietone
#141 interdiff-136-141.txt1.86 KBquietone
#138 interdiff_131-136.txt3.43 KBkishor_kolekar
#136 2687849-136.patch29.08 KBkishor_kolekar
#131 2687849-131.patch29.21 KBquietone
#131 interdiff-129-131.txt1.89 KBquietone
#129 DuringRollback.png114.65 KBquietone
#129 2687849-129.patch30.02 KBquietone
#129 interdiff-124-129.txt11.21 KBquietone
#126 Before.png20.33 KBquietone
#126 After.png26.92 KBquietone
#124 interdiff_122-124.txt1.09 KBvsujeetkumar
#124 2687849_124.patch32.09 KBvsujeetkumar
#122 2687849-122.patch32.05 KBayushmishra206
#122 interdiff_120-122.txt1.16 KBayushmishra206
#120 RollbackComplete.png87 KBquietone
#120 RollbackStart.png38.39 KBquietone
#119 2687849-120.patch32.04 KBquietone
#119 interdiff-118-120.txt1.62 KBquietone
#118 2687849-118.patch33.74 KBquietone
#118 interdiff-116-118.txt558 bytesquietone
#116 2687849-116.patch33.74 KBquietone
#116 interdiff-114-116.txt2.33 KBquietone
#114 2687849-114.patch34.36 KBquietone
#114 interdiff-112-114.txt1.89 KBquietone
#112 2687849-112.patch33.8 KBquietone
#112 interdiff-110-112.txt1.75 KBquietone
#110 2687849-110.patch33.68 KBquietone
#110 interdiff-108-110.txt1.13 KBquietone
#108 2687849-108.patch33.37 KBquietone
#108 interdiff-103-108.txt4.43 KBquietone
#103 2687849-103.patch30.13 KBquietone
#103 interdiff-101-103.txt1.44 KBquietone
#101 2687849-101.patch30.15 KBquietone
#101 interdiff-99-101.txt3.18 KBquietone
#99 interdiff-91-99.txt2.58 KBVidushi Mehta
#99 rerolled-2687849-99.patch28.28 KBVidushi Mehta
#95 2687849-95.patch11.2 KBVidushi Mehta
#91 diff-88-91.txt675 bytesshaktik
#91 2687849-91.patch28.31 KBshaktik
#88 interdiff_84-87.txt676 bytesshaktik
#88 2687849-87.patch28.31 KBshaktik
#84 2687849-84.patch27.65 KBquietone
#84 diff-77-84.txt4.11 KBquietone
#82 2687849-test-82.patch36.06 KBquietone
#81 2687849-81.patch36.48 KBquietone
#81 diff-77-81.txt12.75 KBquietone
#77 2687849-77.patch28.48 KBquietone
#77 interdiff-75-77.txt5.45 KBquietone
#75 2687849-75.patch28.42 KBquietone
#75 interdiff-73-75.txt2.69 KBquietone
#73 2687849-73.patch28.35 KBquietone
#73 interdiff-71-73.txt17.11 KBquietone
#71 2687849-71.patch24.98 KBquietone
#71 interdiff-69-71.txt4.13 KBquietone
#69 2687849-69.patch24.63 KBquietone
#69 diff-64-69.txt6.9 KBquietone
#64 2687849-64.patch27.94 KBquietone
#55 interdiff.txt1.96 KBquietone
#55 2687849-55.patch28.12 KBquietone
#53 2687849-53.patch26.16 KBquietone
#50 interdiff-48-50.txt4.73 KBquietone
#50 2687849-50.patch25.75 KBquietone
#48 interdiff-46-48.patch7.14 KBquietone
#48 2687849-48.patch25.83 KBquietone
#46 2687849-46.patch22.98 KBquietone
#38 2687849-28.patch9.05 KBrakesh.gectcr
#38 2687849-WIP-36.patch6.21 KBrakesh.gectcr
#28 interdiff-26-28.txt13.23 KBpiggito
#28 2687849-28.patch17.1 KBpiggito
#26 interdiff-24-26.txt1.15 KBpiggito
#10 rollbacks_ui-2687849-10.patch19.2 KBanish.a
#26 2687849-26.patch7.92 KBpiggito
#24 2687849-24.patch7.89 KBpiggito
#5 interdiff.txt579 bytesquietone
#5 2687849-5.patch19.23 KBquietone
#17 2687849-17.patch9.66 KBrakesh.gectcr
#3 2687849-3.patch18.52 KBquietone
#12 add_back_rollbacks-2687849-12.patch19.2 KBmikeryan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm created an issue. See original summary.

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

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

quietone’s picture

This is postponed on #2687843: Add back incremental migrations through the UI, which has differing opinions on whether it should be implemented or not. In light of that on going discussion, and if rollback is still wanted in the UI, here is a patch for the rollback action. This includes a new confirmation message for both the upgrade and rollback actions.

Also, the proposed resolution includes 'Consider refactoring the form and batch process so the logic for it is not entangled with the initial migration and the rollback option.' Note that there are two existing issues pertaining to that #2687851: Refactor run() method on Migrate UI batch and remove the $operation parameter and #2679929: Reduce method and control structure length/complexity in Migrate UI.

Status: Needs review » Needs work

The last submitted patch, 3: 2687849-3.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
19.23 KB
579 bytes

Updated the test to use the new text.

quietone’s picture

Had a chat with alexpott on IRC. The short version is that we agree that rollback is useful. It provides an 'undo' function which is something many expect to have in software. And that means they can then 'undo' instead of re-install to fix simple things like installing or un-installing a module.

What do you think? Time to review this?

Here is the full conversation:
quietone: re the UI and rollback - I really don't know. This is one tricky area
quietone: when talking to other migrate maintainers it seems as though the migrate UI in core is viewed as a one chance casino
alexpott, I was wondering if some would prefer a full rollback and try again, say after install some modules, instead of resinstalling and trying again
s/install/installing/
quietone: that is a possible use-case I guess - but i'd prefer people to re-install. Cleaner. But OTOH this is incremental-lite :D
quietone: that use-case is probably the best use-case for an "incremental" ish thing in the UI. - Something that only allows you to run new migrations that are available.
quietone: But the idea of only have a "do it" and "undo it" button in the migrate UI might be a really good idea.
alexpott, do it / undo it. Ah, that 'feels' right.
quietone: so the workflow is install core & a few modules... run migrate - think nope - rollback - install or uninstall modules - migrate - thing yay!
quietone: feel free to copy this IRC chat into the issue
alexpott, yes, I think that fits for those who will be using the UI.

xjm’s picture

If we don't want to add incremental migrations because D6 and D7 did not support incremental updates, wouldn't the same reasoning mean rollback was out of scope, since D6 and D7 did not support rolling back update.php? Also in the other issue one of the statements was that we would not support migration into a non-empty site in core. I don't see the value of supporting rollback in the UI if you always have to start from an empty site anyway. What's the point of rolling back to an empty site?

To me incremental migrations are a much more essential feature than this.

quietone’s picture

@xjm, as alexpott said "But the idea of only have a "do it" and "undo it" button in the migrate UI might be a really good idea." I think that is the reason, it gives those working just from the UI a way to 'Undo'. And it means they don't have to re-enter the database credentials and file path information.

kekkis’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch from #5 won't apply.

Checking patch core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php...
Hunk #2 succeeded at 745 (offset 24 lines).
Hunk #3 succeeded at 807 (offset 24 lines).
Hunk #4 succeeded at 928 (offset 24 lines).
Hunk #5 succeeded at 1012 (offset 24 lines).
Hunk #6 succeeded at 1026 (offset 24 lines).
Hunk #7 succeeded at 1131 (offset 24 lines).
Hunk #8 succeeded at 1208 (offset 24 lines).
Hunk #9 succeeded at 1227 (offset 24 lines).
Checking patch core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php...
Hunk #1 succeeded at 61 (offset 2 lines).
Hunk #2 succeeded at 127 (offset 1 line).
error: while searching for:
              $context['sandbox']['num_processed'], 'Upgraded @migration (processed 1 item total)', 'Upgraded @migration (processed @num_processed items total)',
              ['@migration' => $migration_name, '@num_processed' => $context['sandbox']['num_processed']]);
          }
          $context['sandbox']['messages'][] = $message;
          static::logger()->notice($message);
          $context['sandbox']['num_processed'] = 0;

error: patch failed: core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php:141
error: core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php: patch does not apply
Checking patch core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php...
anish.a’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
19.2 KB

Rerolled against 8.2.x branch.

mikeryan’s picture

Assigned: Unassigned » mikeryan
mikeryan’s picture

Status: Needs review » Needs work
FileSize
19.2 KB

I needed to reroll this, patch attached.

With this patch, I was not able to run an import in the first place - clicking Continue on the overview form simply reloaded it without proceeding to the credentials form (not clear on why that is).

  1. +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
    @@ -21,6 +21,16 @@ class MigrateUpgradeForm extends ConfirmFormBase {
       /**
    +   * If a migration has previously run, perform an incremental migration.
    +   */
    +  const MIGRATE_UPGRADE_INCREMENTAL = 1;
    

    Incremental upgrades are not being added, at least in this patch, so no point in adding this constant.

  2. +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
    @@ -735,10 +745,19 @@ public function buildOverviewForm(array $form, FormStateInterface $form_state) {
    +      $form['upgrade_option'] = array(
    +        '#type' => 'radios',
    +        '#title' => $this->t('You can rollback the upgrade.'),
    +        '#default_value' => static::MIGRATE_UPGRADE_ROLLBACK,
    +        '#options' => [
    +          static::MIGRATE_UPGRADE_ROLLBACK => $this->t('<strong>Rollback</strong>: Remove content and configuration entities (such as fields and node types). Default values of other configuration will not be reverted (such as site name).'),
    +        ],
    +      );
    

    There's not much point to a radio select with only one option. This would probably be better as just a simple value with a description making it clear that continuing will perform a rollback.

mikeryan’s picture

Assigned: mikeryan » Unassigned

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.

mikeryan’s picture

Issue tags: +Migrate UI
rakesh.gectcr’s picture

Assigned: Unassigned » rakesh.gectcr

working on it.

rakesh.gectcr’s picture

Had mentioned about this issue in the weekly migration call, according to the priority this will be taking care of end of July 2017.
However worked on roll back against 8.4.x, which is attached.
To do,

  1. [#12] has to addressed
  2. /core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php No more existing, So that IMHO the following code has to moved to /core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php
    /**
    diff --git a/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php b/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php
    index 2a271fb..e96d1b2 100644
    --- a/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php
    +++ b/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php
    @@ -61,7 +61,7 @@ class MigrateUpgradeRunBatch {
        * @param int[] $initial_ids
        *   The full set of migration IDs to import.
        * @param string $operation
    -   *   The operation to perform. Only 'import' is currently supported.
    +   *   The operation to perform, 'import' or 'rollback'.
        * @param array $config
        *   An array of additional configuration from the form.
        * @param array $context
    @@ -127,6 +127,9 @@ public static function run($initial_ids, $operation, $config, &$context) {
             if ($operation == 'import') {
               $migration_status = $executable->import();
             }
    +        else {
    +          $migration_status = $executable->rollback();
    +        }
           }
           catch (\Exception $e) {
             static::logger()->error($e->getMessage());
    @@ -142,6 +145,11 @@ public static function run($initial_ids, $operation, $config, &$context) {
                   $context['sandbox']['num_processed'], 'Upgraded @migration (processed 1 item total)', 'Upgraded @migration (processed @count items total)',
                   ['@migration' => $migration_name]);
               }
    +          else {
    +            $message = static::getTranslation()->formatPlural(
    +              $context['sandbox']['num_processed'], 'Rolled back @migration (processed 1 item total)', 'Rolled back @migration (processed @num_processed items total)',
    +              ['@migration' => $migration_name, '@num_processed' => $context['sandbox']['num_processed']]);
    +          }
               $context['sandbox']['messages'][] = (string) $message;
               static::logger()->notice($message);
               $context['sandbox']['num_processed'] = 0;
    @@ -210,6 +218,13 @@ public static function run($initial_ids, $operation, $config, &$context) {
                 '@max' => $context['sandbox']['max'],
               ]) . "<br />\n" . $context['message'];
             }
    +        else {
    +          $context['message'] = t('Currently rolling back @migration (@current of @max total tasks)', [
    +              '@migration' => $migration_name,
    +              '@current' => $context['sandbox']['current'],
    +              '@max' => $context['sandbox']['max'],
    +            ]) . "<br />\n" . $context['message'];
    +        }
           }
         }
         else {
    @@ -252,6 +267,9 @@ protected static function displayResults($results) {
           if ($results['operation'] == 'import') {
             drupal_set_message(new PluralTranslatableMarkup($successes, 'Completed 1 upgrade task successfully', 'Completed @count upgrade tasks successfully'));
           }
    +      else {
    +        drupal_set_message(static::getTranslation()->formatPlural($successes, 'Completed 1 rollback task successfully', 'Completed @count rollback tasks successfully'));
    +      }
         }
     
         // If we had failures, log them and show the migration failed.
    @@ -260,6 +278,10 @@ protected static function displayResults($results) {
             drupal_set_message(new PluralTranslatableMarkup($failures, '1 upgrade failed', '@count upgrades failed'));
             drupal_set_message(new TranslatableMarkup('Upgrade process not completed'), 'error');
           }
    +      else {
    +        drupal_set_message(static::getTranslation()->formatPlural($failures, '1 rollback failed', '@count rollbacks failed'));
    +        drupal_set_message(t('Rollback process not completed'), 'error');
    +      }
         }
         else {
           if ($results['operation'] == 'import') {
    @@ -267,6 +289,9 @@ protected static function displayResults($results) {
             // but we didn't have failures so this is fine.
             drupal_set_message(new TranslatableMarkup('Congratulations, you upgraded Drupal!'));
           }
    +      else {
    +        drupal_set_message(t('Rollback of the upgrade is complete - you may now start the upgrade process from scratch.'));
    +      }
         }
     
mikeryan’s picture

Version: 8.3.x-dev » 8.4.x-dev
Priority: Major » Normal

Moving to 8.4.x and reducing to Normal - this is not a requirement for the migration system being declared "stable", which is our goal for 8.4.0, this is new functionality we would target for post-stability.

joelpittet’s picture

Assigned: rakesh.gectcr » Unassigned
Status: Needs work » Needs review

Status: Needs review » Needs work

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

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

quietone’s picture

Issue summary: View changes

Updated the IS to include adding documentation to the handbook. Aside from being a nice idea in general, this is a to do item on #2561249: [Meta] Reorganization of (some) d.o. migration documentation, see #11.

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.

piggito’s picture

Status: Needs review » Needs work

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

piggito’s picture

Status: Needs work » Needs review
FileSize
7.92 KB
1.15 KB

Fixing consts misplacing.

Status: Needs review » Needs work

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

piggito’s picture

Status: Needs work » Needs review
FileSize
17.1 KB
13.23 KB

Added ./core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeRollbackBatch.php + code standard fixes.

heddn’s picture

Status: Needs review » Postponed
Issue tags: +drupal.org documentation, +Needs documentation

This could use some documenting. I'm also going to pend it on #2918761: Break up MigrateUpgradeForm into smaller forms.

quietone’s picture

Status: Postponed » Needs work
Issue tags: +Needs reroll

No longer postponed, and will need a reroll.

quietone’s picture

Status: Needs work » Postponed

It was reverted, back to postponed.

masipila’s picture

1. I created a documentation follow-up and updated the issue summary accordingly, see #2947498: Document Migrate Drupal UI rollbacks.

2. Regarding the UI for this. The original screenshot what this used to look like back in the days said 'Rerun'. I propose we use the term 'Incremental upgrade' consistently.

Cheers,
Markus

quietone’s picture

Issue summary: View changes

32.2 I agree and have updated the IS. We can add a UX review when this is ready to be sure, but it is certainly better than 'rerun'.

quietone’s picture

Status: Postponed » Needs work
quietone’s picture

Issue summary: View changes
rakesh.gectcr’s picture

Assigned: Unassigned » rakesh.gectcr

Assiging for reroll

rakesh.gectcr’s picture

rakesh.gectcr’s picture

quietone’s picture

Status: Needs work » Needs review

Setting to NR for testbot

The last submitted patch, 38: 2687849-WIP-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

rakesh.gectcr’s picture

Status: Needs review » Needs work
heddn’s picture

Priority: Normal » Major

This is on the roadmap for 8.6, so let's bump priority.

quietone’s picture

Issue tags: -Needs reroll +Needs tests

Nice to see progress here. Tagging for needing a test.

Took a brief look at the patch #28 and it looks like a base class for the Batch would be useful.

rakesh.gectcr’s picture

Assigned: rakesh.gectcr » Unassigned

Un assigining myself, for time being some one wants to pik it up..

quietone’s picture

Assigned: Unassigned » quietone

Let's bring this up-to-date.

quietone’s picture

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

This far from complete. I've added a test, adding a rollback at the end of the existing full migration test. There is a new method, getEntityCountsRollback() to get the entity counts for the post rollback assertions but they are all wrong, it is just a copy/paste from getEntityCounts() because I haven't looked into the counts yet but I wanted to get the test built. Running the tests to see how bad this is.

There is no interdiff because I applied the two patches in #38 and started from there.

Status: Needs review » Needs work

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

quietone’s picture

Status: Needs work » Needs review
FileSize
25.83 KB
7.14 KB

This addressed coding standard errors, a adjusted the assertion in FormStepTest for the new text on the Incremental form, and fixes and the problem where I hastily put getEntityCountsRollback in the wrong class.

Still very much a WIP and no need for review yet.

Edit: my fingers really like to name the interdiff wrong these days!

Status: Needs review » Needs work

The last submitted patch, 48: interdiff-46-48.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
25.75 KB
4.73 KB

Only a bit of cleanup. Fixed the remaining coding standard errors and changed drupal_set_message to \Drupal::messenger().

Status: Needs review » Needs work

The last submitted patch, 50: 2687849-50.patch, failed testing. View results

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

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.

quietone’s picture

Status: Needs work » Needs review
FileSize
26.16 KB

Rerolling the patch.

Status: Needs review » Needs work

The last submitted patch, 53: 2687849-53.patch, failed testing. View results

quietone’s picture

This may fix two tests, the NoMultilingual ones.

quietone’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 55: 2687849-55.patch, failed testing. View results

quietone’s picture

I seem to be at an impasse and don't see how to fix this. Can anyone provide some direction.

quietone’s picture

Assigned: quietone » Unassigned

Un-assigning myself since I can't see the problems here.

quietone’s picture

Retesting

quietone’s picture

This is failing on the page reload after the rollback finishes.

1) Drupal\Tests\migrate_drupal_ui\Functional\d6\MigrateUpgrade6Test::testMigrateUpgradeExecute
Exception: Error: Call to a member function url() on null
rdf_comment_storage_load()() (Line: 244)

Maybe this this related one or more of these #2978320: [backport] rdf comment storage load should not load NULL comments, #2614720: Fatal errors while loading/building orphaned comments or #2906470: Orphan comments and entries in comment_entity_statistics after comment field instance has been deleted ?

quietone’s picture

Retesting

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.

quietone’s picture

Status: Needs work » Needs review
FileSize
27.94 KB

Just a reroll

Status: Needs review » Needs work

The last submitted patch, 64: 2687849-64.patch, failed testing. View results

firfin’s picture

I seem to have this functionality already? Or is that because it is currently in migrate_tools or migrate_plus already (or for now)?

quietone’s picture

I haven't used migrate_tools in a long time but the core UI does not offer any type of rollback.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs work » Needs review
FileSize
6.9 KB
24.63 KB

Another reroll

Status: Needs review » Needs work

The last submitted patch, 69: 2687849-69.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
4.13 KB
24.98 KB

Add getEntityCountsRollback() to several tests, remove unnecessary validation from the IncrementalForm and get the migrations from the store for use in the rollback.

Status: Needs review » Needs work

The last submitted patch, 71: 2687849-71.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
17.11 KB
28.35 KB

The current Upgrade6Test and Upgrade7Test logout the admin user and when I try to log back in as the root user it fails because the password has changed. So, instead of having to keep track of the password from the test fixture this patch makes new tests Rollback6Test and Rollback7Test. This patch also includes the latest patch from #3123095: Rollback of complete node migration fails so that the node complete migration actually does rollback the nodes.

While I am still not fond of testing the entity counts it is the best we have so entity counts are tested post rollback. The counts in the patch are not correct, and I expect failures.

Status: Needs review » Needs work

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

quietone’s picture

Status: Needs work » Needs review
FileSize
2.69 KB
28.42 KB

Add the source_base_path for Rollback7Test and some cleanup.

Status: Needs review » Needs work

The last submitted patch, 75: 2687849-75.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
5.45 KB
28.48 KB

Update entity counts.

Status: Needs review » Needs work

The last submitted patch, 77: 2687849-77.patch, failed testing. View results

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Add related issue to comment, #38 over there.

quietone’s picture

Status: Needs work » Needs review
FileSize
12.75 KB
36.48 KB

The patch in needed a reroll and I am curious to see if adding #2614720: Fatal errors while loading/building orphaned comments will fix the error.

quietone’s picture

I'll make a proper rerolled patch after this test.

Status: Needs review » Needs work

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

quietone’s picture

Status: Needs work » Needs review
FileSize
4.11 KB
27.65 KB

It appears that the #2614720: Fatal errors while loading/building orphaned comments does improve the outcome here but I can't be sure. I'll have to test locally.

Here is a reroll of the patch in #77

Status: Needs review » Needs work

The last submitted patch, 84: 2687849-84.patch, failed testing. View results

shaktik’s picture

I am working on testcases

shaktik’s picture

Status: Needs work » Needs review

the fixing test case, let's wait for the boat.

shaktik’s picture

quietone’s picture

@shaktik, thanks for the patch.

There's a typo.

+++ b/core/modules/migrate/src/MigrateExecutable.php
@@ -306,7 +306,7 @@ public function rollback() {
+      if (issset($destination_key)) {

s/issset/isset/

Status: Needs review » Needs work

The last submitted patch, 88: 2687849-87.patch, failed testing. View results

shaktik’s picture

Status: Needs work » Needs review
FileSize
28.31 KB
675 bytes

sorry for typo error, fixed typo error.

@quietone, Thank you for quick check.

Status: Needs review » Needs work

The last submitted patch, 91: 2687849-91.patch, failed testing. View results

shaktik’s picture

I am trying to fix but not completed still getting some issue in this method testMigrateUpgradeExecute, here is the link for the testing patch I tried https://www.drupal.org/project/drupal/issues/3164847#comment-13792232

quietone’s picture

+++ b/core/modules/migrate/src/MigrateExecutable.php
@@ -306,7 +306,7 @@ public function rollback() {
       $destination_key = $id_map->currentDestination();
-      if ($destination_key) {
+      if (isset($destination_key)) {

MigrateIdMapInterface::currentDestination can return an array, including an empty array. So, instead of isset try !empty.

Vidushi Mehta’s picture

Status: Needs work » Needs review
FileSize
11.2 KB

Added a patch as mentioned by #94.

quietone’s picture

@Vidushi Mehta, thank you for the patch. Can you provide an interdiff?

shaktik’s picture

@quietone,

Thanks for the suggestion I also tried with !empty, but no luck.

Haha Bot's happy. @Vidushi Mehta thanks for the patch. but why you skipped all new files in the previous patch any Specific reason?

Thanks,
Shakti

quietone’s picture

Status: Needs review » Needs work

@shaktik, thanks for pointing that out the lost files.

So, this needs another reroll, from #91, that adds the fix suggested in #94.

I also noticed that Rolback7Test is a copy/paste of Rollback6Test and that needs to be fixed.

  1. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Rollback6Test.php
    @@ -0,0 +1,102 @@
    +namespace Drupal\Tests\migrate_drupal_ui\Functional\d6;
    ...
    + * Tests Drupal 6 rollback using the migrate UI.
    ...
    +class Rollback6Test extends Upgrade6Test {
    

    s/6/7

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Rollback6Test.php
    @@ -0,0 +1,102 @@
    +  protected function assertFollowUpMigrationResults() {
    

    Replace this with the method of the same name from Upgrade7Test

Vidushi Mehta’s picture

Status: Needs work » Needs review
FileSize
28.28 KB
2.58 KB

Rerolled the patch and added the new files which was missed by me to add @shaktik sorry for that. I've added point 2 which was mentioned by @quietone but still point 1 is not covered as I didn't understand this point/change properly. @quietone & @shaktik it would be really helpful if you guys help me in this or @shaktik if you can cover this point.

Status: Needs review » Needs work

The last submitted patch, 99: rerolled-2687849-99.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
3.18 KB
30.15 KB

@Vidushi Mehta, thanks. Sorry about the confusion. The string 's/6/7', means change 6 to 7 but that is moot because I made a mistake. I was looking at the wrong file so my #98.1 and #98.2 are wrong.

I have made a new patch to correct my mistake. Note this also includes a change in \Drupal\migrate\MigrateExecutable::rollback to check that $map_row is an array.

Status: Needs review » Needs work

The last submitted patch, 101: 2687849-101.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
1.44 KB
30.13 KB

Rollback7Test is failing because of recent changes to the functional tests. This patch makes those changes, I hope (it is late).

The Rollback6Test is failing, https://www.drupal.org/pift-ci-job/1796503, on an rdf issue. For that the patch from #2978320: [backport] rdf comment storage load should not load NULL comments should be added. I am not doing that here because I want to see if there any other errors related to the changes in the functional tests. There shouldn't be any.

Status: Needs review » Needs work

The last submitted patch, 103: 2687849-103.patch, failed testing. View results

Vidushi Mehta’s picture

@quietone no issues reagrding your commnet on #101. But after all that changes still the Rollback6Test is failing.

quietone’s picture

Yes, the tests are failing. In #103 I said that the patch from #2978320: [backport] rdf comment storage load should not load NULL comments is needed. That still needs to be done. But even with that I expect it will fail the same was as the Drupal 7 test.

So, look at the test results for the Drupal 7 test and check out what it is failing on. That will give us an indication of the problem.

Are you setup to run these functional tests locally?

quietone’s picture

quietone’s picture

Status: Needs work » Needs review
FileSize
4.43 KB
33.37 KB

Let's add a method for testing the rollback results. Modified drupalci.yml to just run the migrate_drupal_ui tests.

Status: Needs review » Needs work

The last submitted patch, 108: 2687849-108.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
1.13 KB
33.68 KB

That is not what I meant to do. This should be better, though still a work in progress.

Status: Needs review » Needs work

The last submitted patch, 110: 2687849-110.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
1.75 KB
33.8 KB

Better, now add a string to confirm the rollback and update entity counts.

Status: Needs review » Needs work

The last submitted patch, 112: 2687849-112.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
1.89 KB
34.36 KB

Change some more entity_counts

Status: Needs review » Needs work

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

quietone’s picture

Status: Needs work » Needs review
FileSize
2.33 KB
33.74 KB

And cleanup and fix more entity counts

Status: Needs review » Needs work

The last submitted patch, 116: 2687849-116.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
558 bytes
33.74 KB

Missed another entity count

quietone’s picture

Now restore drupalci.yml

quietone’s picture

Issue summary: View changes
FileSize
38.39 KB
87 KB

Update the IS

quietone’s picture

Status: Needs review » Needs work
Issue tags: +Novice
+++ b/core/modules/migrate_drupal_ui/src/Form/IncrementalForm.php
@@ -78,16 +96,20 @@ public function buildForm(array $form, FormStateInterface $form_state) {
+        static::MIGRATE_UPGRADE_INCREMENTAL => $this->t('<strong>Rerun</strong>: Import additional configuration and content that was not available when running the upgrade previously.'),

According the IS this should be 'Incremental upgrade' instead of 'Rerun'. Once that change is made a new screenshot needs to be added to the IS to replace the existing one of this page.

Making that change is suitable for a novice task, so tagging.

ayushmishra206’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.16 KB
32.05 KB

Made the changes requested in #121. Please review

quietone’s picture

Status: Needs review » Needs work

@ayushmishra206, thanks. That looks correct. Can you also make a screenshot and update the Issue Summary?

vsujeetkumar’s picture

Status: Needs work » Needs review
FileSize
32.09 KB
1.09 KB

Fixing test.

quietone’s picture

Status: Needs review » Needs work

@vsujeetkumar, thanks for fixing the test.

Setting to NW for a screenshot of the changed page. That screenshot should be in the IS.

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Novice
FileSize
26.92 KB
20.33 KB

Added screenshots.

heddn’s picture

Issue tags: +Needs usability review

Probably could use a usability review of the screens in the IS. Tagging.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Did a self review. Found some items to cleanup and removed use of deprecated code.

quietone’s picture

Assigned: Unassigned » quietone

Needs a reroll which I will finish tonight.

quietone’s picture

Rerolled and removed third parameter from a call to updateEntity that looks left over from an earlier design of this.

There are no changes that warrant creating new screen shots.

quietone’s picture

Assigned: quietone » Unassigned
quietone’s picture

Issue tags: +Needs reroll
quietone’s picture

Status: Needs review » Needs work
vsujeetkumar’s picture

Assigned: Unassigned » vsujeetkumar
kishor_kolekar’s picture

Assigned: vsujeetkumar » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
29.08 KB

re-roll the patch.

quietone’s picture

Status: Needs review » Needs work
Issue tags: +Novice

@kishor_kolekar, can you add the interdiff? There are instructions for creating an interdiff in the handbook.

Creating the diff is suitable for a novice, adding tag.

kishor_kolekar’s picture

Status: Needs work » Needs review
Issue tags: -Novice
FileSize
3.43 KB

Thanks, @quietone for your feedback...

benjifisher’s picture

Status: Needs review » Needs work
Issue tags: -Needs usability review +Needs change record

Usability review

We discussed this issue at #3182480: Drupal Usability Meeting 2020-11-20.

The interface text looks fine. The only thing we did not like was handling the documentation page in a separate issue. Instead of adding the documentation page in #2947498: Document Migrate Drupal UI rollbacks, can we add it as part of this issue?

If you think that the documentation deserves a new page, then we can add the page now, but do not add it to the menu of the Upgrading Drupal guide. In practice, no one will find the page until we add it to the menu, but to be safe we can add a note at the top that it depends on this issue being fixed.

If you think the new documentation should be part of an existing page, then we could add a stub section now, saying that rollbacks will be possible once this issue is fixed. We could add a draft of the final text as a comment to this issue.

Either way, the patch here should be updated to add a link to the new documentation. I am setting the status to NW for that.

Probably this issue should also have a change record. I am adding the tag for that.

Last point: the new option says,

Remove content and configuration entities (such as fields and node types). Default values of other configuration will not be reverted (such as site name).

The new documentation should expand on that, with examples. I read that sentence two or three times before I realized that the key word is "entities".

quietone’s picture

Issue summary: View changes
Issue tags: -Needs change record

Change record added.

Closed #2947498: Document Migrate Drupal UI rollbacks based on the usability review.

What is still to do is to add the documentation and update the patch. Leaving at NW

I think the documentation should be on the existing page, Upgrade using web browser, in a new section 'Starting the upgrade'. The new section would be for discussing the Overview Form, which has a version for when no migration has run and for when a migration has run.

quietone’s picture

Status: Needs work » Needs review
FileSize
1.86 KB
29.24 KB

Updated Upgrade using web browser, with a new section, 'Start', that will be explaining the Overview and Incremental forms.

I have removed the word 'entities' from the text for two reasons, one is the comment in #139 and the other is a memory of reading an issue that I can no longer find about not using the entity is user facing text. I reckon for many folk 'entity' has no meaning but the words content and configuration do and are sufficient here.

quietone’s picture

And a new screen shot

Status: Needs review » Needs work

The last submitted patch, 141: 2687849-141.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
3.75 KB
29.2 KB

That was silly. I changed the text but not the tests.

benjifisher’s picture

Assigned: Unassigned » benjifisher

I have removed the word 'entities' from the text ...

Good call. I think the reference you are looking for is Interface text > Word Choice. But the text now reads,

Remove content and configuration (such as fields and node types). Default values of other configuration will not be reverted (such as site name).

What is the difference between "configuration", as in "content and configuration", and "other configuration"? Is this variant accurate?

Remove content and configuration, such as fields and node types. Default values of simple configuration, such as site name, will not be reverted.

I prefer commas instead of parentheses, but I do not insist on it.

We will need to update the screenshot in the CR to show the updated text.

I am assigning the issue to myself for a code review. I plan to finish today.

benjifisher’s picture

Assigned: benjifisher » Unassigned
Status: Needs review » Needs work
  1. This new test class has one test method, which seems to be a duplicate of MigrateNodeCompleteTest::testRollbackNodeComplete().

     +++ b/core/modules/node/tests/src/Kernel/Migrate/d7/RollbackNodeCompleteTest.php
     @@ -0,0 +1,44 @@
  2. This change looks like an unrelated bug fix. If so, then it is out of scope for this issue. Should we create a follow-up issue, and add test coverage for whatever bug this is fixing?

     +++ b/core/modules/migrate/src/MigrateExecutable.php
     @@ -313,14 +313,16 @@ public function rollback() {
     ...
            $destination_key = $id_map->currentDestination();
     -      if ($destination_key) {
     +      if (!empty($destination_key)) {
              $map_row = $id_map->getRowByDestination($destination_key);
     -        if ($map_row['rollback_action'] == MigrateIdMapInterface::ROLLBACK_DELETE) {
     -          $this->getEventDispatcher()
     -            ->dispatch(new MigrateRowDeleteEvent($this->migration, $destination_key), MigrateEvents::PRE_ROW_DELETE);
     -          $destination->rollback($destination_key);
     -          $this->getEventDispatcher()
     -            ->dispatch(new MigrateRowDeleteEvent($this->migration, $destination_key), MigrateEvents::POST_ROW_DELETE);
     +        if (is_array($map_row)) {
     +          if ($map_row['rollback_action'] == MigrateIdMapInterface::ROLLBACK_DELETE) {
     +            $this->getEventDispatcher()
     +              ->dispatch(new MigrateRowDeleteEvent($this->migration, $destination_key), MigrateEvents::PRE_ROW_DELETE);
     +            $destination->rollback($destination_key);
     +            $this->getEventDispatcher()
     +              ->dispatch(new MigrateRowDeleteEvent($this->migration, $destination_key), MigrateEvents::POST_ROW_DELETE);
     +          }
              }
  3. Same here:

     +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
     @@ -276,10 +276,13 @@ public function rollback(array $destination_identifier) {
     ...
     -      $config = $this->storage->load($entity_id)->getConfigDependencyName();
     -      $config_override = $this->languageManager->getLanguageConfigOverride($language, $config);
     -      // Rollback the translation.
     -      $config_override->delete();
     +      // Ensure the entity exists before attempting to delete.
     +      if (!is_null($this->storage->load($entity_id))) {
     +        $config = $this->storage->load($entity_id)->getConfigDependencyName();
     +        $config_override = $this->languageManager->getLanguageConfigOverride($language, $config);
     +        // Rollback the translation.
     +        $config_override->delete();
     +      }
          }
  4. Can we use StringTranslationTrait and then use $this->t() and whatever the plural version is called?

     +++ b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeRollbackBatch.php
     @@ -0,0 +1,211 @@
     ...
     +use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
     +use Drupal\Core\StringTranslation\TranslatableMarkup;
  5. Maybe MESSAGE_COUNT or MAX_MESSAGE_COUNT instead of MESSAGE_LENGTH:

     ...
     +  /**
     +   * Maximum number of previous messages to display.
     +   */
     +  const MESSAGE_LENGTH = 20;
  6. Do we have to allow for the possibility that ’$initial_ids == []`?

     +  public static function run(array $initial_ids, array $config, array &$context) {
     +    if (!isset($context['sandbox']['migration_ids'])) {
     ...
     +      // migration_ids will be the list of IDs remaining to run.
     +      $context['sandbox']['migration_ids'] = $initial_ids;
     ...
     +    }
     ...
     +    $migration_id = reset($context['sandbox']['migration_ids']);
  7. I have seen this code before! Should we postpone this issue on #2925899: MigrateUpgradeImportBatch does not use source_private_file_path & source_base_path correctly, making it impossible to have public & private files in separate locations? Better yet, can we avoid duplicating code between the two Batch classes?

     +    // @todo Find a way to avoid this in https://www.drupal.org/node/2804611.
     +    if ($definition['destination']['plugin'] === 'entity:file') {
     +      // Make sure we have a single trailing slash.
     +      if ($definition['source']['plugin'] === 'd7_file_private') {
     +        $configuration['source']['constants']['source_base_path'] = rtrim($config['source_private_file_path'], '/') . '/';
     +      }
     +      $configuration['source']['constants']['source_base_path'] = rtrim($config['source_base_path'], '/') . '/';
     +    }

    In fact, now that I know where to look, I really do not like how much code is duplicated between the two Batch classes. I think some refactoring is in scope for this issue. Also, the last lines quoted above are missing another recent change, #3151363: Double // in file paths.

  8. Do we want to make rollback the default option, not incremental migration? (Is this discussed in earlier comments?)

  9. Break before ->createInstances():

     +++ b/core/modules/migrate_drupal_ui/src/Form/IncrementalForm.php
     @@ -95,15 +120,54 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ...
     +  protected function doRollback() {
     +    $config['source_base_path'] = $this->store->get('source_base_path');
     +
     +    $migrations = $this->migrationPluginManager->createInstances(array_keys($this->store->get('migrations')));
  10. I think we will have to update the two functional tests once #3175953: Cleanup migrate drupal functional tests is fixed.

  11. Is this method declared somewhere else?

     +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Rollback6Test.php
     @@ -0,0 +1,82 @@
     ...
     +  /**
     +   * {@inheritdoc}
     +   */
     +  protected function getEntityCountsRollback() {
quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
12.71 KB
31.5 KB
28.54 KB

@benjifisher, thanks for the review.

145. Text changed, no more parentheses.

146.
1. Looks like a left over file. It is not needed. The rollback test is now part of MigrateNodeCompleteTest.
2. todo
3. todo
4. Don't think this can be changed because this is a static method.
5. I'd rather not do that here. Could be a followup.
6. I don't know, I just copied from MigrateUpgradeImportBatch.
7. Added a base class with a method for this bit of code.
8. There has been no discussion of what the default should be. Probably should not change it though, so it is 'Incremental'.
9. Fixed.
10. Yes, that is very likely.
11. There is a method called getEntityCountsRollback in both Rollback6Test and Rollback7Test. Even though those tests are so similar i decided not to make yet another base class.

One new screenshot added. showing the default of Incremental and the new text for rollback.

benjifisher’s picture

Status: Needs review » Needs work
Issue tags: +Needs followup

@quietone, thanks for the update. There is a lot here!

  • #145: Shorter text is probably better, and we have a link to the more complete explanation.
  • #146.1: Thanks
  • #146.2, #1476.3: todo
  • #146.4: Right, static functions always mess me up.
  • #146.7, #146.8, #146.9: Thanks
  • #146.11: Since there is no base class and no interface for these two classes, we should not use {@inheritdoc} for the getEntityCountsRollback() methods.

Adding the base class is a big help. I agree that we can postpone further work to a follow-up issue. There is still a lot of code that is duplicated in the run() method, and I would like to move that to the base class. It should handle all the sandbox management. The important thing for now is that we have isolated the code that we know is going to change from #3151363: Double // in file paths (already fixed) and #3175953: Cleanup migrate drupal functional tests (RTBC). We can handle #146.5, #146.6 in the follow-up issue.

Just one more request for the new base class:

    +++ b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeBatchBase.php
    @@ -0,0 +1,56 @@
    +<?php
    +
    +namespace Drupal\migrate_drupal_ui\Batch;
    +
    +/**
    + * Base class for migrations.
    + */
    +class MigrateUpgradeBatchBase {

Make the class comment a little more specific: something like "Base class for migration batch operations."

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs followup
FileSize
1.83 KB
31.78 KB
29.82 KB

@benjifisher, thanks.

Nice, only comment changes!

146.11. Yes, of course. Just got confused, I am so used to seeing inheritdoc on the getEntityCount* methods I didn't even notice.
148. Thanks. I didn't like that class comment either.

Added followup. #3191590: [PP-1] Refactor Migrate Drupal UI batch classes.

And added another screenshot, so all the screenshots are up to date now.

benjifisher’s picture

Status: Needs review » Needs work

Still NW for #146.2, #146.3. Those look like unrelated bug fixes, but maybe there is a reason to include them here.

Thanks for creating the follow-up issue.

-   * {@inheritdoc}
+   * Gets expected number of entities per entity after rollback.

That should be "... per entity type ...".

quietone’s picture

Status: Needs work » Needs review
FileSize
2.9 KB
30.17 KB

146.2 The change in MigrateExecutable was added in #88 and is not needed.

146.3 The change in EntityConfigBase was added in #73 and tests fail if it is not included. I am pretty sure it has to do with dependencies. For d6 it fails when rolling back d6_profile_field_option_translation but I am just not seeing what dependency is incorrect. However, even with that I do think that testing the entity exists before deleting it is a good practice and this change should stay.

This patch removes the change to MigrateExecutable and updates the comments as per #150.

benjifisher’s picture

Issue summary: View changes
  1. Thanks for reverting the change pointed out in #146.2 (MigrateExecutable). I am updating the Proposed resolution to mention the change pointed out in #146.3:

     +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
     @@ -276,10 +276,13 @@ public function rollback(array $destination_identifier) {
     ...
     +      // Ensure the entity exists before attempting to delete.
     +      if (!is_null($this->storage->load($entity_id))) {
     +        $config = $this->storage->load($entity_id)->getConfigDependencyName();

    Can we make it simply if ($this->storage->load($entity_id))? If so, then break the long line while you are at it.

    Either way, this change looks completely safe. I guess the test failure is shown in Upgrade7Test in the tests for #71. If we want to add an issue to investigate the dependency problem, that is a good place to start. Even if we fix that, it is easy for someone working on a site upgrade to delete individual content items, then do a rollback. We do not want a PHP error when that happens, so a check for NULL here is a good idea.

  2. The last things we need to do are the documentation updates. Is the CR up to date (including screenshots)? I am updating the issue summary since we are doing #2947498: Document Migrate Drupal UI rollbacks as part of this issue. Can we add some proposed text for Upgrade using web browser to a comment or the issue summary?

benjifisher’s picture

Status: Needs review » Needs work
quietone’s picture

Issue summary: View changes

I updated the CR with a new screenshot and a text change from 'button' to 'option'.

Suggestion for the doc, update the Start paragraph from

If an upgrade was not done then the Upgrade page provides information about the preparation steps that should be done before continuing with the upgrade. However, if an upgrade was done then you are asked if you want to import new configuration and content. If you continue, for either of these situations, you are then asked to define the source site.

to

If an upgrade was not done then the Upgrade page provides information about the preparation steps that should be done before continuing with the upgrade. However, if an upgrade was done then you are asked if you want to import new configuration and content or to rollback the upgrade. If you continue, for any of these situations, you are then asked to define the source site.

quietone’s picture

Status: Needs work » Needs review

Follow up created to figure out what is suspected to be a dependency problem, #3191782: Fix dependency in d6 user profile translation migrations When that happens the error is

1) Drupal\Tests\migrate_drupal_ui\Functional\d6\Rollback6Test::testMigrateUpgradeExecute
Exception: Error: Call to a member function getConfigDependencyName() on null
Drupal\migrate\Plugin\migrate\destination\EntityConfigBase->rollback()() (Line: 279)

152.1 It is reasonable to think that the error from the tests in #71 would should the error generated by the dependency problem but it does not. I am pretty sure that error was caused by #2978320: [backport] rdf comment storage load should not load NULL comments. The error message here must have appeared locally and fixed. I guess I could add a fail patch, but I don't think that is necessary because testing that an entity exists before deleting it is a sensible thing to do.

I think that is everything, back to NR.

benjifisher’s picture

Status: Needs review » Needs work
  1. I also asked in #152.1 if we could remove the !is_null(). Can we?
  2. The proposed text in #154 does not say much more than the form itself. As I said in #139, the documentation page should say more about what will and will not be rolled back. In the latest patch, the form has less information about that than it did when I added that comment.
quietone’s picture

Status: Needs work » Needs review
FileSize
978 bytes
30.14 KB

156.1 Yes. Is this better?
156.2 Suggested text:
If an upgrade was not done then the Upgrade page provides information about the preparation steps that should be done before continuing with the upgrade. However, if an upgrade was done then you are asked if you want to import new configuration and content or to rollback the upgrade. If you continue, for any of these situations, you are then asked to define the source site.

A rollback will remove all the content that was added to the site by an upgrade or an incremental upgrade but not all configuration. Configuration, such as fields and their settings will be removed but configuration such as the basic site settings are not restored to their previous value.

benjifisher’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the update for #156.1.

The proposed text in #157 is a good start. I think this issue is ready!

adityasingh’s picture

Patch at #157 is conflicting with issue MigrateUpgradeImportBatch does not use source_private_file_path & source_base_path correctly, making it impossible to have public & private files in separate locations commit ID 42aa2b1.

This is why I believe #157 is failing and needs some work with respect to the conflicting commit, adding patch for this kindly review.

adityasingh’s picture

Status: Reviewed & tested by the community » Needs review
quietone’s picture

Status: Needs review » Needs work

Thanks for the reroll.

+++ 2687849-159.patch	2021-01-27 14:03:36.515535410 +0530
--  /**
--    $definition = \Drupal::service('plugin.manager.migration')->getDefinition($migration_id);
--    $configuration = [];
--    // @todo Find a way to avoid this in https://www.drupal.org/node/2804611.
--    if ($definition['destination']['plugin'] === 'entity:file') {
--      // Make sure we have a single trailing slash.
--      if ($definition['source']['plugin'] === 'd7_file_private') {
--        $configuration['source']['constants']['source_base_path'] = rtrim($config['source_private_file_path'], '/') . '/';
--      }
--      $configuration['source']['constants']['source_base_path'] = rtrim($config['source_base_path'], '/');
--    }
-+    $configuration = static::configure($config, $migration_id);
- 
-     /** @var \Drupal\migrate\Plugin\Migration $migration */
-     $migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id, $configuration);
+    * @var \Drupal\migrate\Plugin\MigrationInterface[]

This part of the diff looks wrong. There is a change that got lost in the reroll. MigrateUpgradeImportBatch should be using the new configure method that is in the new Base class., $configuration = static::configure($config, $migration_id);

Here is the excerpt from the patch in #157 showing the change that needs to be restored.

+++ b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php
@@ -108,17 +89,7 @@ public static function run($initial_ids, $config, &$context) {
-    $definition = \Drupal::service('plugin.manager.migration')->getDefinition($migration_id);
-    $configuration = [];
-
-    // @todo Find a way to avoid this in https://www.drupal.org/node/2804611.
-    if ($definition['destination']['plugin'] === 'entity:file') {
-      // Make sure we have a single trailing slash.
-      if ($definition['source']['plugin'] === 'd7_file_private') {
-        $configuration['source']['constants']['source_base_path'] = rtrim($config['source_private_file_path'], '/') . '/';
-      }
-      $configuration['source']['constants']['source_base_path'] = rtrim($config['source_base_path'], '/');
-    }
+    $configuration = static::configure($config, $migration_id);

This is what was lost.

abhisekmazumdar’s picture

Status: Needs work » Needs review
FileSize
30.41 KB
1.64 KB

Added the missed out part. Kindly review.

huzooka’s picture

Maybe this is also related: #3186449: Rolling back a migration implementing MigrationWithFollowUpInterface does not clear the generated follow up migrations from the cache..

We had issues with the d7_entity_reference_translation migrations when we tried to roll back migrations.

Our workaround was:

  • We wrote a smart migration_lookup plugin.

    • This new plugin is able to identify those migrations (even more) which had the appropriate source rows, even when the lookup was done with partial source identifiers (e.g: searching based on a source node ID only instead of node ID + node revision ID + langcode).
    • Based on an array with the matching source rows (IDs), it creates stubs for every identified (matching) row, and returned the destination IDs.
  • We replaced the entity reference field migration plugins with our own implementation – basically, when an entity reference field's target is node, it returns a field value process pipeline which uses this "smarter" migration_lookup plugin in defineValueProcessPipeline().
  • Since the node entity reference fields got the appropriate entity reference ID right after the parent entity migration, we were able to completely ignore the currently known d7_entity_reference_translation migrations.
quietone’s picture

@huzooka, I fail to see the connection between the entity reference migrations and rolling back via the UI. The problems encountered in this patch concerned RDF and orphan comments.

Status: Needs review » Needs work

The last submitted patch, 162: 2687849-162.patch, failed testing. View results

huzooka’s picture

@quietone,

If you roll back node migrations, including node types, then the source plugin used by etr migrations will throw an exception.

benjifisher’s picture

quietone’s picture

Status: Needs work » Needs review
FileSize
1.97 KB
29.07 KB

This was discussed at the migrate meeting so lets get this passing tests. So rerolling. And I think my review in #161 was incorrect. Apologies.

huzooka’s picture

  1. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
    @@ -276,10 +276,13 @@ public function rollback(array $destination_identifier) {
    -      $config = $this->storage->load($entity_id)->getConfigDependencyName();
    -      $config_override = $this->languageManager->getLanguageConfigOverride($language, $config);
    -      // Rollback the translation.
    -      $config_override->delete();
    +      // Ensure the entity exists before attempting to delete.
    +      if ($entity = $this->storage->load($entity_id)) {
    +        $config = $entity->getConfigDependencyName();
    +        $config_override = $this->languageManager->getLanguageConfigOverride($language, $config);
    +        // Rollback the translation.
    +        $config_override->delete();
    +      }
    

    I'm almost sure this is a workaround for #3187415: Module settings translation migrations should depend on the default settings migration. Has anyone ever checked what are the configs that make this necessary?

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Rollback6Test.php
    @@ -0,0 +1,85 @@
    +  /**
    +   * Executes all steps of migrations upgrade and rollback.
    +   */
    +  public function testMigrateUpgradeExecute() {
    +    MigrateUpgradeExecuteTestBase::testMigrateUpgradeExecute();
    +
    +    // Test rollback.
    +    $this->drupalGet('/upgrade');
    +    $session = $this->assertSession();
    +    $session->pageTextContains('An upgrade has already been performed on this site. For more information, see the upgrading handbook.');
    +    $session->pageTextContains('Rollback: Remove configuration and content. Some configuration values, such as site name, will not be reverted.');
    +    $rollback = ['upgrade_option' => IncrementalForm::MIGRATE_UPGRADE_ROLLBACK];
    +    $rollback_edits = $this->translatePostValues($rollback);
    +    $this->submitForm($rollback_edits, 'Continue');
    +    $session->pageTextContains('Rollback of the upgrade is complete - you may now start the upgrade process from scratch.');
    +    $this->assertRollback($this->getEntityCountsRollback());
    +  }
    

    It would be nice to test a re-import after this rollback.

quietone’s picture

160.1 For d6 these config entities are null when the rollback attempts to delete them. My first guess is dependency problem.

  • user.profile_sold_to zu
  • user.profile_sold_ to fr
  • user.profile_count_trees fr

169.2 I added that but I will be surprised it the entity count assertions pass.

166. @huzooka, can you provides steps to reproduce?

Also, I checked and the followup migrations are not rolled back. :-(

Instead of providing rollback through the UI we need to consider not doing this and have people reinstall, or reload a fresh db. If this is wanted I would like to postpone it on #3082211: Migrate UI upgrade tests should provide the complete log and #3084477: Bulk output entity count errors from migrate_drupal_ui tests.

quietone’s picture

#169.1 - I forgot I made an issue for that, #3191782: Fix dependency in d6 user profile translation migrations

Status: Needs review » Needs work

The last submitted patch, 170: 2687849-170.patch, failed testing. View results

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review

Discussed at #3203113: [meeting] Migrate Meeting 2021-03-11 and there is support for marking this as won't fix. As of this writing benjifisher, heddn and myself participated in the discussion.

In summary, the reasons are:

  • Rollback can probably be considered an additional feature and not necessarily block a stable Migrate UI. (from earlier revision of this issue)
  • The state of the site after rollback will not be the same as a fresh install
  • Can break the site (configuration is not rolled back)
  • Explaining how rollback works will be complicated. How to explain that rollback does NOT put the site back into the same state as before the migration.
  • If the migration results are not as expected it is easy to drop the site and start over - or switch to drush.

Is there any objection to marking this won't fix?

quietone’s picture

Issue summary: View changes
xjm’s picture

Thanks @quietone. Since this affects the product aspects of Migrate as well as the features available to improve data integrity, I'm tagging for Product and Release Manager review.

catch’s picture

So for me personally, still need to discuss this more with @xjm too:

Even though I use drush to run migrations, I prefer re-installing and re-migrating to using rollback, because I know I'm doing exactly the same thing each time. It potentially means a lot longer to run commands, but it's more reliable and can be running in the background. Dealing with rollback means I have to wait for the rollback to finish before re-migrating, and if something goes wrong there are more possible reasons.

If we did offer rollback through the UI, is this going to just be rolling back an entire migration/set of migrations, or would we also offer options like specifying a range or specific entities to rollback?

If it's the latter, we can't expect site admins to specify entity IDs manually like the drush command does, so it starts to look more like VBO (although not sure what VBO would look like for this). If we don't offer those options, then there's not that much difference from requiring that people reinstall and re-migrate - I think there's an issue elsewhere to offer a reinstall button that we could revive though.

quietone’s picture

is this going to just be rolling back an entire migration/set of migrations,

Yes. It will rollback all the discovered migrations.

webchick’s picture

Hm. Migrate UI went stable in #2905491: Mark Migrate Drupal UI as stable (thanks for the archeology, @Gábor Hojtsy! :D) so we're good there in terms of this being a stable blocker.

I completely understand the Migrate team not wanting to work on this feature, due to its complexity and user impact (or lack thereof), and the desire to focus the team's effort elsewhere that's more impactful... that's perfectly fine.

But I don't quite understand why we'd "won't fix" what seems like a perfectly reasonable feature request here. Like, if an enterprising contributor comes along and donates time to bring it home, or Acquia someday decides to fully open source Acquia Migrate Accelerate, which has this feature... I don't think we'd want to say we explicitly don't want the feature to roll back migrations..? The UI matching what the API can do seems desirable, as a general rule?

xjm’s picture

Based on #178, maybe we just downgrade this to normal? The scope is large but it sounds like the priority is not so much.

quietone’s picture

Acquia Migrate Accelerate, which has this feature.

How does that handle config migrations which do not rollback to the state before the upgrade was run?

webchick’s picture

Priority: Major » Normal

Fair, it does not. :) But even still, rolling back content migrations is quite a useful feature to have.

Trying the "normal" downgrade on for size.

quietone’s picture

If rolling back content is useful, then let's change this to do just that, to rollback only content. That will be easier to do (with the possible exception of blocks) and definitely easier to explain.

benjifisher’s picture

Issue summary: View changes

It has been almost two weeks since the last comment. I will update the issue summary as suggested, changing the scope of the issue so that it only rolls back the content migrations.

Maybe the hardest part will be documenting what that means.

I think it makes a lot of sense to separate configuration migrations from content migrations. I usually run configuration migrations early, then start tracking configuration as usual and never run those migrations again. All the iteration is on the content migrations. I think I feel the need for a follow-up issue ...

marvil07’s picture

Title: Add back rollbacks through the UI » Add back rollbacks on migrate_drupal_ui

It is confusing at times to refer to migrate_drupal_ui as Migrate UI.
When I think about Migrate UI I think on a general UI for migrate, but this issue is about migrate_drupal_ui, which is specific for Drupal to Drupal migrations.
Just making a note and changing the title to avoid some confusion.

quietone’s picture

FileSize
922 bytes
29.16 KB

The patch needed a reroll. Not running tests as they will fail anyway, just posting it for reference.

quietone’s picture

FileSize
6.64 KB
31.38 KB

This works locally to rollback content and re-import it. Again, not running test because they will fail.

This changes the incremental form so that what an upgrade is performed an option to Rollback is given. Then, once the rollback has run and one returns to the incremental form, via /upgrade, the option to Rollback is replaced with an option to upgrade content.

quietone’s picture

Adding a new test. The d6 tests fails but it is tool late to investigate that now.

Status: Needs review » Needs work

The last submitted patch, 187: 2687849-187.patch, failed testing. View results

KapilV’s picture

Status: Needs work » Needs review
FileSize
15.44 KB
KapilV’s picture

FileSize
32.29 KB
KapilV’s picture

FileSize
559 bytes
quietone’s picture

@kapilkumar0324, when you create a patch it is helpful to comment on the changes you have made an why you have made them. That makes it so much easier to review. Looking at the interdiff it looks like you are trying to get the tests to pass. In this case, that is not the next step, which my comment in #187 was trying to express. That first investigation needs to be done to understand why the entity counts have changed and document it.

KapilV’s picture

@quietone thank you for the suggestion.

Status: Needs review » Needs work

The last submitted patch, 190: 2687849-190.patch, failed testing. View results

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sahil.goyal’s picture

reroll the patch for the current version so it is now been compatible and attaching the Reroll patch for the same.

_utsavsharma’s picture

Fixed CCF for #200.
Please review.

steinmb’s picture

Thank you for contributing and keeping this issue alive:

* Are these a re-roll of #187?
* Please try to include a interdiff

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.