Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hudri/2731c8184c050c724be5f5aa8b577abb to your computer and use it in GitHub Desktop.
Save hudri/2731c8184c050c724be5f5aa8b577abb to your computer and use it in GitHub Desktop.
Drupal 8: Insert default values for in newly added paragraphs fields
insert into paragraph__FIELD_NEWFIELD (bundle, deleted, entity_id, revision_id, langcode, delta, FIELD_NEWFIELD_value)
select type, 0, id, revision_id, langcode, 0, DEFAULT_FIELD_VALUE from paragraphs_item where type = 'PARENT_PARAGRAPH_TYPE';
insert into paragraph_revision__FIELD_NEWFIELD (bundle, deleted, entity_id, revision_id, langcode, delta, FIELD_NEWFIELD_value)
select type, 0, id, revision_id, langcode, 0, DEFAULT_FIELD_VALUE from paragraphs_item where type = 'PARENT_PARAGRAPH_TYPE'
@hudri
Copy link
Author

hudri commented May 29, 2018

do this ONCE IMMEDTIALY after creating adding the new field to the paragraph. no security checks at all. not tested with multi cardinality, multi language or multi revisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment