Closed (won't fix)
Project:
Default Content
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 May 2018 at 16:11 UTC
Updated:
4 Apr 2022 at 18:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
andypostLooks like duplicate #2698425: Do not re-import existing entities
Comment #3
jjchinquistThis isn't a duplicate. Our desired workflow is that we have a set of default content that represents much of the abilities of the website. We import it for testing instances of the website, not on production. So we import all content into an empty database. It has to do with when default content is updated in two separate branches of the project and then conflicts are created due to the ID numbers being in conflict.
Comment #4
Phil Wolstenholme commentedI'm running into this issue very frequently too.
Comment #5
RumyanaRuseva commentedThis is not a duplicate of #2698425: Do not re-import existing entities but it's related.
I believe there should be an option in the export command flagging whether the entity id should be exported. The module is designed to work with uuid as main identifier, and we usually do not need to export the entity id.
As a workaround you can currently manually edit the exported json file and remove the entity id to avoid conflicts.
Importer works perfectly with empty entity id.
Comment #6
geerlingguy commentedSame issue here, and the workaround posted by @RumyanaRuseva worked well.
Comment #7
michael_wojcik commentedTaking inspiration from @RumyanaRuseva in #5, I made a patch that adds a new drush option `--skip-entity-ids` to the existing drush commands, which will allow users to automatically remove all references to specific entity IDs during the content export process. The resulting JSON files can then be imported into any existing Drupal environment without worrying about conflicting IDs in the database. This work resulted from a real-world use case where we needed to leverage the default_content module to import content into an already existing site in Production.
Comment #9
Phil Wolstenholme commented#7 gave me a
The "--skip-entity-ids" option does not exist, perhaps because I am using Drush 9?I'll take a look at
src/Commands/DefaultContentCommands.phpand see if I can update the patch this afternoon.Comment #10
Phil Wolstenholme commentedHere's an updated patch that adds (hopefully!) Drush 9+ support. I don't use Drush 8 so haven't been able to check whether Drush 8 has been affected by my changes. This patch hasn't been tested in production or any other environment as I stopped working on it after discovering that Entity Reference Revisions fields (e.g. the ones used for Paragraphs) require an ID, so this patch and similar ones will break references to Paragraphs on your site.
I've attached some related issues, this idea could work if ERR updates to allow serialised ERR fields to use a UUID rather than target ID.
Comment #11
berdirI've created a new 2.0.x branch that uses a custom normalization and the ids and a lot of other things that are not useful are not exported anymore.
1.x is in maintenance mode and and won't receive future features anymore.
Comment #12
Phil Wolstenholme commented@Berdir that sounds excellent! Does it get around the Entity Reference Revisions issue by putting the nested entities in a single file rather than linking Paragraphs across multiple files by ID?
Comment #13
berdirYes, 2.0.x supports ERR composite entities like paragraphs out of the box and puts them in a single file. We already did that in the past with a patch for default_content and one for ERR, but now it just works. See the project page for more features of the 2.0.x branch.
I'm closing isuses that are resolved in 2.0.x as won't fix as the 1.x branch isn't actively maintained anymore and new features won't be implemented.
Comment #14
meanderix commented@Berdir How does 2.0.x handle non-numeric entity ids? AFAICT this results in error
Field 'id' doesn't have a default valueupon import.Comment #15
berdirthat's quite possible, but that's a different issue than this. Patches to check for ID being an integer/serial are welcome.