Migrate command aborts with SQL error / default value

Created on 23 May 2024, 6 months ago
Updated 10 September 2024, 2 months ago

Problem/Motivation

The drush command drush smart_date:migrate workshop field_when field_core_daterange without the parameter --clear does not skip entities with default values, it throws an exception on the console and aborts:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-0-0-de' for key 'PRIMARY'

The documentation for the option --clear β†’ says:

  • Remove any existing data in the destination field. Unless this option is specified, existing data will not be removed.

This happens when i configure a default value of default_date_type: now for the field but disable the field in form_display of my node. But i dont think it has anything to do with the field being disabled.

Steps to reproduce

  1. Create a content_type event
  2. Add a core date-field field_core_daterange for event
  3. Enable smart_date, smart_date_recur
  4. Add new field field_event_when to content_type event with default value of "now"
  5. Disable the field field_event_when in the form_display for event
  6. Create a node of type event
  7. Enable the field field_event_when in the form_display for event
  8. Run the drush command to migrate the data: drush smart_date:migrate event field_event_when field_core_daterange

Proposed resolution

Don't let the command crash - or if intended - update the documentation for the --clear parameter.

πŸ› Bug report
Status

RTBC

Version

4.1

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany harkonn

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024