Problem/Motivation
Currently, manual imports/exports, with the changes done in
this issue β
, works fine. However, there exists a point that can improve the performance: all content is imported/exported although there aren't changes. This means that the first process of import/export has a reasonable execution time, but the next ones could spend more time than needed. In some cases, it may save just seconds, but in large projects with a large amount of default content, it may save a big amount of time.
I've preferred opening a new issue instead of continuing in the
original one β
so that:
- The original issue is finished without needing to check additional changes
- Although the proposed changes will make the default content work faster, probably it exceeds the scope of the module is done for (something I don't know and I would like to confirm).
In case you see this feature useful I would propose to postpone this issue until
https://www.drupal.org/node/2640734 β
is solved, and setting it as a 'Feature request' instead of a support request.
Proposed resolution
1. With a table that registers a row for every exported/imported content it is possible to detect when a content is changed, without needing to load the entities. This table would contain:
- Module
- FOlder
- Entity ID
- Entity type
- Entity uuid
- Hash: this contains a hashed version of the imported/exported file and it is the most important table property.
2. DUring import, only import when the hash has changed, or it does not exist in the table. After importing an entity, a registry is added or updated in the table with the content hash.
3. When an entity is updated and it has a registry in the table with the same uuid, update the table with the new hash.
4. When an entity is deleted, delete the registry using the uuid if exists.
5. Create a new export command that receives the module name and updates the content with changes (checking the hash between the database and the exported YAML file is different). This command would iterate over the table rows matching the module name and exporting them to the module content folder.