Problem/Motivation

The Umami Demo install profile uses bespoke code to create its content from a collection of CSV, HTML and image files. However, #2931739: Bring migrate_source_csv to core is targeted for inclusion in 8.6.x and it would be great to adopt migrate via the new CSV source plugin as soon as possible when that lands.

Proposed resolution

Replace the code in Drupal\demo_umami_content\InstallHelper methods with migrations, executed at install time.

Note this is speculative work at this time as #2931739: Bring migrate_source_csv to core is yet to land. Also when/if #2954378: Use Media images in Umami demo is complete, tweaks to the import process will be needed as we'll be migrating media items as well as images.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#4 2983573-4.patch12.52 KBmohit_aghera
#3 2983573-3.patch991 bytesmartin_q
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Eli-T created an issue. See original summary.

Eli-T’s picture

martin_q’s picture

FileSize
991 bytes

To simplify the migration work, I've created a separate users.csv file and a user import. In recipes.csv I replaced the user names with user IDs. Then in the recipes import I've got a migration lookup which finds out the uid in the imported site and uses that as the author for the recipe. I've modified the articles.csv file in the same way. @Mohit, you'd need to change the articles import in the same way to use the imported users.

mohit_aghera’s picture

Status: Active » Needs work
FileSize
12.52 KB

Implementing initial patch for article migration implementation.
Updated following things:
- Added changes from #3 patch.
- Added migration for importing article content item

Right now i have commented actual function callback that imports content that imports content, i.e. below snippet in "demo_umami_content_install()" hook.

  if (!\Drupal::service('config.installer')->isSyncing()) {
    //\Drupal::classResolver(InstallHelper::class)->importContent();
  }

Instead of this, we are using article migration to import content.

To run and test on local: we need to apply patch from #2931739

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.

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.

DuaelFr’s picture

FYI #2931739: Bring migrate_source_csv to core has been closed as "Won't fix" :/

Eli-T’s picture

Status: Needs work » Closed (won't fix)

Moving to won't fix also due to the previous comment

martin_q’s picture

With all the attention OOTB gets these days, I have been feeling bad about not ever getting around to completing my work on this. I guess if it's no longer feasible then it's fortunate I didn't. I take it there isn't another flat file format for which migrate has a module in core already?

DuaelFr’s picture

@martin_q You could find a workaround by using the embedded_data source and altering the migration at runtime to provide the data as an array.
You could gather the data from a Json file and preprocess it with \Drupal\Component\Serialization\Json::decode() by yourself, or keep building the data array from a CSV file like you currently do.