Problem/Motivation

After Installing, uninstalling, then attempting to reinstall Migrate Example, it fails because of the following error:

Unable to install Migrate Example Setup, comment.type.node_comments, core.entity_form_display.comment.node_comments.default, core.entity_form_display.node.migrate_example_beer.default, core.entity_view_display.comment.node_comments.default, core.entity_view_display.node.migrate_example_beer.default, core.entity_view_display.node.migrate_example_beer.teaser, field.field.comment.node_comments.comment_body, field.field.node.migrate_example_beer.body, field.field.node.migrate_example_beer.field_comments, field.field.node.migrate_example_beer.field_migrate_example_beer_style, field.field.node.migrate_example_beer.field_migrate_example_country, field.field.node.migrate_example_beer.field_migrate_example_image, field.field.user.user.field_migrate_example_favbeers, field.field.user.user.field_migrate_example_gender, field.storage.node.field_comments, field.storage.node.field_migrate_example_beer_style, field.storage.node.field_migrate_example_country, field.storage.node.field_migrate_example_image, field.storage.user.field_migrate_example_favbeers, field.storage.user.field_migrate_example_gender, node.type.migrate_example_beer, taxonomy.vocabulary.migrate_example_beer_styles already exist in active configuration.

It happens because the example configuration created on module install is not removed after uninstalling.

The same problem applies to other example modules: Migrate Example (Advanced), Migrate JSON Example.

Steps to reproduce

1. Install "Migrate Example";
2. Uninstall "Migrate Example" and "Migrate Example Setup";
3. Install "Migrate Example" again.

Proposed resolution

Add enforced dependency to module config files. It'll make sure the config files are remove on module uninstall.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TrevorBradley created an issue. See original summary.

TrevorBradley’s picture

Manual cleanup procedure (to permit reinstall):

Administration > Structure > Content Types: Delete Beer
Administration > Structure > Comment Types: Delete Node Comments
Administration > Configuration > People > Account Settings > Manage Fields: Delete Favorite Beers AND Gender
Administration > Structure > Taxonomy: Edit Vocabulary Migrate Example Beer Styles. Delete.

shawnmatthews’s picture

I am also experiencing this issue with both 3.0-beta1 and 3.x-dev.

Is there a work around?

I'm experiencing with both the example and advanced example in Drupal

TrevorBradley’s picture

@shawnmatthews: I've not tried it for the advanced example, but presumably the procedure would be similar. Walk through the errors and delete Content Types, Comment Types, Added People fields, Vocabularies, and whatever other fields the advanced example has to allow for a reinstall. Looking at advanced - that's a lot more steps...

I really do believe this is a bug though.

/modules/migrate_plus/migrate_example/migrate_example_setup/migrate_example_setup.install

and

/modules/migrate_plus/migrate_example_advanced/migrate_example_advanced_setup/migrate_example_advanced_setup.install

Both should be implementing hook_uninstall().

The migrate_example modules are fun to have around, but after the party is over, they leave a mess of spilled beer and wine all over the place and don't stick around to clean up...

shawnmatthews’s picture

Haha thanks! I removed the lines from the DB and away it all went.

shawnmatthews’s picture

http://www.jeffgeerling.com/blog/2016/migrate-custom-json-feed-drupal-8-...

Additionally, See notes at the bottom of this article for developing around "exsits in active configuration."

All the best,
Shawn

joshi.rohit100’s picture

Yes! that is problem in migration plus as it doesn't delete config while uninstall. You can write a uninstall hook for deleting config from DB or you can delete config manually from DB every time you uninstall module.

cruno’s picture

I'm adding a patch that includes hook_uninstall() implementations for both migrate_example and migrate_example_advanced.

It also includes 2 drush commands that will help with this problem and issues where people are experiencing this problem in their own custom modules.

The first simply does the what the hook_uninstall() implementations do except they take in a module name as an argument, the second removes them but also re-registers them.
So any changes or additions to the configs for the given module will be updated without needing to uninstall and re-install the module again.

DamienMcKenna’s picture

Version: 8.x-3.0-beta1 » 8.x-3.x-dev
Status: Active » Needs review

Don't forget to mark the issue "needs review" after you upload a patch.

mikeryan’s picture

Status: Needs review » Needs work

Actually, I think the best solution here would be to do as migrate_example does for the migration configurations:

dependencies:
  enforced:
    module:
      - migrate_example

If we added

dependencies:
  enforced:
    module:
      - migrate_example_setup

to migrate_example/migrate_example_setup/config/install/*.yml, it should clean itself up.

mpriscella’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev
FileSize
10.73 KB
9.07 KB

This is an update to @cruno's patch that adds the Drush 9 style commands for the migrate-remove-configs and migrate-reregister-migrations drush commands.

Frank Ralf’s picture

Reinstalling Migrate Example and Migrate Example Advanced does work on my machine with Drupal 8.4.4 even if some configuration settings aren't deleted. The Easy Install module can help cleaning up after an incomplete uninstall.

heddn’s picture

#10 from above is the way to go. NW for that.

Matroskeen’s picture

Title: Unable to reinstall Migrate Example » Configuration is not cleaned on uninstall process of example modules (Migrate Example, Migrate Example (Advanced), Migrate JSON Example)
Version: 8.x-4.x-dev » 8.x-5.x-dev
Issue summary: View changes

I'm updating the issue summary. The merge request is coming...

Matroskeen’s picture

Status: Needs work » Needs review
FileSize
5.28 KB
26.22 KB

The first commit was supposed to fail, let's try patches.

The last submitted patch, 16: 2822737-16-test-only.patch, failed testing. View results

Matroskeen’s picture

Test only patch failed as expected. The merge request is ready for review.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

  • Matroskeen committed b7aaf9a on 8.x-5.x
    Issue #2822737 by Matroskeen, mpriscella, cruno: Configuration is not...

  • Matroskeen committed 767b981 on 6.0.x
    Issue #2822737 by Matroskeen, mpriscella, cruno: Configuration is not...
Matroskeen’s picture

Status: Reviewed & tested by the community » Fixed

Merged to 8.x-5.x and cherry-picked to 6.0.x.
Thank you!

Status: Fixed » Closed (fixed)

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