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.
Comment | File | Size | Author |
---|
Issue fork migrate_plus-2822737
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:
Comments
Comment #2
TrevorBradley CreditAttribution: TrevorBradley commentedManual 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.
Comment #3
shawnmatthews CreditAttribution: shawnmatthews commentedI 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
Comment #4
TrevorBradley CreditAttribution: TrevorBradley commented@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...
Comment #5
shawnmatthews CreditAttribution: shawnmatthews commentedHaha thanks! I removed the lines from the DB and away it all went.
Comment #6
shawnmatthews CreditAttribution: shawnmatthews commentedhttp://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
Comment #7
joshi.rohit100Yes! 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.
Comment #8
cruno CreditAttribution: cruno commentedI'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.
Comment #9
DamienMcKennaDon't forget to mark the issue "needs review" after you upload a patch.
Comment #10
mikeryanActually, I think the best solution here would be to do as migrate_example does for the migration configurations:
If we added
to migrate_example/migrate_example_setup/config/install/*.yml, it should clean itself up.
Comment #11
mpriscella CreditAttribution: mpriscella at Group Nine Media, Inc. commentedThis is an update to @cruno's patch that adds the Drush 9 style commands for the
migrate-remove-configs
andmigrate-reregister-migrations
drush commands.Comment #12
Frank Ralf CreditAttribution: Frank Ralf commentedReinstalling 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.
Comment #13
heddn#10 from above is the way to go. NW for that.
Comment #14
MatroskeenI'm updating the issue summary. The merge request is coming...
Comment #16
MatroskeenThe first commit was supposed to fail, let's try patches.
Comment #18
MatroskeenTest only patch failed as expected. The merge request is ready for review.
Comment #19
heddnComment #22
MatroskeenMerged to 8.x-5.x and cherry-picked to 6.0.x.
Thank you!