Use Migrate for importing content?

Created on 11 August 2016, almost 8 years ago
Updated 24 March 2023, over 1 year ago

Problem/Motivation

The Default Content module might benefit from using Migrate to control the import of content:

  • Benefit from available Migrate processor plugins
  • Allows for alternative sources without too much development, such as remote files or different data structures such as XML
  • Removes the development burden for command line integration
  • Allows for 'Highwater marks', so you keep using Default content while is site is actively being used by editors
  • Allows for 'rolling back' content. This is a very useful feature for updating demo content on an active site.

My team is currently using a similar approach for Drupal7: https://www.drupal.org/project/migrate_defaultcontent β†’ . My current employer is also willing to sponsor development time internally to get this done.

Proposed resolution

Base content imports on Migrations for great benefit.

Remaining tasks

  • Write a patch
  • Review
  • Commit

User interface changes

None

API changes

Yes, to be determined.

Data model changes

Yes, to be determined.

✨ Feature request
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands idebr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Just leaving a comment for those who don't need to export content, but looking for a way to create nodes and terms, for example for content during development, in which case Drupal core module Migrate offers an alternative solution.

    There is a great ressource at https://understanddrupal.com/migrations, and with Migrate module, a custom module with three files is all that is needed to create nodes and terms--not connected in this example, though that is of course possible (code taken from ud_migrations_first and ud_migrations_multivalue_terms):

    ud_migrations_first.info.yml

    type: module
    name: UD First Migration
    description: 'Example of basic Drupal migration.'
    core_version_requirement: ^8 || ^9 || ^10
    dependencies:
      - drupal:migrate
    

    udm_first.yml

    id: udm_first
    label: 'UD First migration'
    source:
      plugin: embedded_data
      data_rows:
        -
          unique_id: 1
          creative_title: 'The versatility of Drupal fields'
          engaging_content: 'Fields are Drupal''s atomic data storage mechanism...'
        -
          unique_id: 2
          creative_title: 'What is a view in Drupal? How do they work?'
          engaging_content: 'In Drupal, a view is a listing of information. It can a list of nodes, users, comments, taxonomy terms, files, etc...'
      ids:
        unique_id:
          type: integer
    process:
      title: creative_title
      body: engaging_content
    destination:
      plugin: 'entity:node'
      default_bundle: page
    

    udm_first_terms.yml

    id: udm_first_terms
    label: 'UD taxonomy term migration'
    source:
      plugin: embedded_data
      data_rows:
        - fruit_name: 'Grape'
          fruit_description: 'Eat fresh or prepare some jelly.'
        - fruit_name: 'Red grape'
          fruit_description: 'Sweet grape'
          fruit_parent: 'Grape'
        - fruit_name: 'White grape'
          fruit_description: 'Sour grape'
          fruit_parent: 'Grape'
        - fruit_name: 'Apple'
          fruit_description: 'Eat fresh or prepare some juice.'
        - fruit_name: 'Red apple'
          fruit_description: 'Sweet apple'
          fruit_parent: 'Apple'
        - fruit_name: 'Green apple'
          fruit_description: 'Sour apple'
          fruit_parent: 'Apple'
      ids:
        fruit_name:
          type: string
    process:
      name: fruit_name
      description: fruit_description
      parent:
        plugin: migration_lookup
        migration: udm_first_terms
        source: fruit_parent
    destination:
      plugin: 'entity:taxonomy_term'
      default_bundle: tags
    

    File structure:

    ud_migrations_first/
    β”œβ”€β”€ migrations
    β”‚   β”œβ”€β”€ udm_first_terms.yml
    β”‚   └── udm_first.yml
    └── ud_migrations_first.info.yml
    
Production build 0.69.0 2024