The following error is thrown when I run the "upgrade_d7_file_entity_image" migration:

Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation:     [error]
1048 Column 'status' cannot be null: INSERT INTO {media_field_data} (mid, vid, bundle, langcode, status,
name, thumbnail__target_id, thumbnail__alt, thumbnail__title, thumbnail__width, thumbnail__height, uid,
created, changed, default_langcode, revision_translation_affected) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4,
:db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8,
:db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12,
:db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array
(
    [:db_insert_placeholder_0] => 461
    [:db_insert_placeholder_1] => 461
    [:db_insert_placeholder_2] => image
    [:db_insert_placeholder_3] => en
    [:db_insert_placeholder_4] => 
    [:db_insert_placeholder_5] => featured-item.png
    [:db_insert_placeholder_6] => 461
    [:db_insert_placeholder_7] => 
    [:db_insert_placeholder_8] => 
    [:db_insert_placeholder_9] => 820
    [:db_insert_placeholder_10] => 250
    [:db_insert_placeholder_11] => 0
    [:db_insert_placeholder_12] => 
    [:db_insert_placeholder_13] => 1561057011
    [:db_insert_placeholder_14] => 1
    [:db_insert_placeholder_15] => 1
)
 in Drupal\Core\Database\Connection->handleQueryException() (line 683 of core/lib/Drupal/Core/Database/Connection.php).
CommentFileSizeAuthor
#2 3063113-fix_status_field_mapping-2.patch1.91 KBslv_

Comments

DamienMcKenna created an issue. See original summary.

slv_’s picture

StatusFileSize
new1.91 KB

I also experienced this recently and looked into it. The problem here comes from the default mapping at "migrations/d7_file_entity.yml":

process:
  mid: fid
  bundle: type
  name: filename
  created: created
  status: published

"Status" is mapped to the "published" field, which is not really present in default drupal setups, nor added by entity_file. It's only present when https://www.drupal.org/project/file_admin is on the Drupal 7 installation. Same happens with the "created" column. That module has a rather low adoption, so the default mapping for those two fields should be:

process:
  mid: fid
  bundle: type
  name: filename
  created: timestamp
  status: status

Aside of the mapping, I've updated the `fields()` method in the source plugin to specify that certain fields are only available if the file_admin module is present in the Drupal 7 installation. No other work done to use one or the other automatically, I think supporting that module out of the box is out of the scope of this task.

Patch attached!

slv_’s picture

Status: Active » Needs review

  • juampynr committed 275b285 on 8.x-1.x authored by slv_
    Issue #3063113 by slv_: 'status' cannot be null
    
juampynr’s picture

Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.