0

I migrate the menu by this drush command:

drush migrate-import --update page_menu

and .yml config:

id: page_menu
label: 'Page menu migration.'
migration_group: pages
source:
  plugin: csv
  path: path_to_file/pages.csv
  delimiter: ';'
  # enclosure: '"'
  header_row_count: 1
  # These are the field names from the source file representing the key
  # uniquely identifying each node - they will be stored in the migration
  # map table as columns sourceid1, sourceid2, and sourceid3.
  keys:
    - id
  column_names:
    0:
      id: 'Unique Id'
    4:
      menu_name: 'Menu'
    5:
      menu_title: 'Menu title'
    6:
      menu_weight: 'Menu item weight'
ids:
  id:
    type: string
destination:
  plugin: entity:menu_link_content
  default_bundle: menu_link_content
  no_stub: true
process:
  bundle: menu_link_content
  title:
    -
      plugin: skip_on_empty
      method: row
      source: menu_title
      message: 'Field field_name is missing'
    -
      plugin: get
  menu_name:
    -
      plugin: skip_on_empty
      method: row
      source: menu_name
      message: 'Field field_name is missing'
    -
      plugin: get
  'link/uri':
    -
      plugin: migration_lookup
      migration: pages
      source: id
    -
      plugin: generate_path
  weight:
    plugin: default_value
    default_value: 0
  expanded:
    plugin: default_value
    default_value: 1
  enabled:
    plugin: default_value
    default_value: 1
  changed: updated
migration_dependencies:
  required:
    - pages
dependencies:
  enforced:
    module:
      - custom_csv_import
      - migrate_source_csv

When I create menu items with this migration first time, the meigration works well. But if I want an update my menu with this command:

drush migrate-import --update page_menu

I get the error "Column 'bundle' cannot be null:":

      [error]  Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'bundle' cannot be null: UPDATE {menu_link_content} SET bundle=:db_update_placeholder_0, uuid=:db_update_placeholder_1, langcode=:db_update_placeholder_2
WHERE id = :db_condition_placeholder_0; Array
(
    [:db_update_placeholder_0] =>
    [:db_update_placeholder_1] => 24013691-38b5-44bf-a981-9961620eb7a2
    [:db_update_placeholder_2] => en
    [:db_condition_placeholder_0] => 21
)
 in Drupal\Core\Database\Connection->handleQueryException() (line 683 of C:\OSPanel\domains\example.loc\web\core\lib\Drupal\Core\Database\Connection.php).
 [error]  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'bundle' cannot be null: UPDATE {menu_link_content} SET bundle=:db_update_placeholder_0, uuid=:db_update_placeholder_1, langcode=:db_update_placeholder_2
WHERE id = :db_condition_placeholder_0; Array
(
    [:db_update_placeholder_0] =>
    [:db_update_placeholder_1] => 24013691-38b5-44bf-a981-9961620eb7a2
    [:db_update_placeholder_2] => en
    [:db_condition_placeholder_0] => 21
)
 (C:\OSPanel\domains\example.loc\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php:783)
 [error]  Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'bundle' cannot be null: UPDATE {menu_link_content} SET bundle=:db_update_placeholder_0, uuid=:db_update_placeholder_1, langcode=:db_update_placeholder_2
WHERE id = :db_condition_placeholder_0; Array
(
    [:db_update_placeholder_0] =>
    [:db_update_placeholder_1] => 36b7ae55-c15e-4be9-a857-ce811e6c9049
    [:db_update_placeholder_2] => en
    [:db_condition_placeholder_0] => 22
)
 in Drupal\Core\Database\Connection->handleQueryException() (line 683 of C:\OSPanel\domains\example.loc\web\core\lib\Drupal\Core\Database\Connection.php).
 [error]  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'bundle' cannot be null: UPDATE {menu_link_content} SET bundle=:db_update_placeholder_0, uuid=:db_update_placeholder_1, langcode=:db_update_placeholder_2
WHERE id = :db_condition_placeholder_0; Array
(
    [:db_update_placeholder_0] =>
    [:db_update_placeholder_1] => 36b7ae55-c15e-4be9-a857-ce811e6c9049
    [:db_update_placeholder_2] => en
    [:db_condition_placeholder_0] => 22
)
 (C:\OSPanel\domains\example.loc\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php:783)

Where I'm wrong?

1

The following basically means
use the default process plugin get to look for a source column or constant named menu_link_content to determine the value for bundle.

process:
  bundle: menu_link_content

which most likely returns null.

Try setting it with the default_value plugin instead:

process:
  bundle:
    plugin: default_value
    default_value: menu_link_content
  • Yes indeed. That helped! – Viktor Apr 12 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.