Score:0

Media migration results in numerous unexpected file usage records (CSV source): How to do this correctly?

ธง pe

I'm migrating lots of records from a non-Drupal site into Drupal 9. The records have file 'attachments,' and I want these to be media in the Drupal site.

I have all the files already on the server where they need to permanently live and have all the paths/URI's stored with all the other site data in CSV files.

Successful so far: I can migrate the URIs into file entities without errors, using the migrate_source_csv module (along with migrate_plus and migration_tools)

The media items have some meta data, so I need to migrate them in separately. This is where results have been interesting.

  • I can migrate the media in from the same source CSV file and use the migration_lookup plugin to create the media entities and relate them to their files.

  • I can also migrate the media in using entity_lookup plugin with very similar results.

In both cases, everything seems normal except that many thousands of file uses of generic.png are generated. Generic.png is not in my source data. I think it comes from the media module.

I can remove these uses from the file_usage table without any apparent negative consequences, but I'm uneasy doing that. This is a partial migration for test purposes, so... 12,552 items created. I hesitate to do the whole thing and move on to migrating in the 'nodes' until I understand what's going on here and potential consequences.

At this stage, I'm using a custom media type called 'document'

The file+media with dependency and migrate_lookup configuration files look like this:

The files file...

uuid: 1bcec3e7-0a49-4473-87a2-6dca09b91abjan-docf
id: docfiles_import
label: "Import files for doc media type"
migration_group: docfilesmedia
source:
  plugin: 'csv'
  path: '/srv/imports/docmedia122.tab'
  delimiter: "\t"
  enclosure: '"'
  header_offset: null
  ids: [filename]
# not using most of these fields in the file import
# but including because maybe needed for grouping
# and migrate_lookup in the media import
  fields:
    0:
      name: filename
      label: 'Unique filename'
    1:
      name: title
      label: 'description'
    2:
      name: doctype
      label: 'document type'
    3:
      name: formflag
      label: 'FormYN'
    4:
      name: newpath
      label: 'path'

process:
  uid:
    plugin: default_value
    default_value: 2
  uri: newpath
  status: 
    plugin: default_value
    default_value: 1
 # 1 equals 'permanent'
destination:
  plugin: entity:file

The media file...

uuid: 1bcec3e7-0a49-4473-87a2-6dca09b91abjan-docmed
id: docmedia_import
label: Import media of document type
migration_group: docfilesmedia

source:
  plugin: 'csv'
  path: '/srv/imports/docmedia122.tab'
  delimiter: "\t"
  enclosure: '"'
  header_offset: null
  ids: [filename]
  fields:
    0:
      name: filename
      label: 'Unique filename'
    1:
      name: title
      label: 'description'
    2:
      name: doctype
      label: 'document type'
    3:
      name: formflag
      label: 'FormYN'
    4:
      name: newpath
      label: 'path'

process:
  name: title
  uid:
    plugin: default_value
    default_value: 179
  field_media_document/target_id:
  # above is name of the file entity ref field
    plugin: migration_lookup
    migration: docfiles_import
    source: filename
    # Unclear how this works. I think it means
    # 'create target ids, using filename field to determine
    # which row to use in the csv file'
  field_doctype_select:
    plugin: entity_generate
    source: doctype
    value_key: name
    bundle: document_type
    entity_type: taxonomy_term
    ignore_case: true
  field_formcheckbox: formflag

migration_dependencies:
  required:
    - docfiles_import
  optional: []

destination:
  plugin: entity:media
  default_bundle: document

The files & media migration examples I've been able to find all have assumptions that differ from my situation (not csv, files need to be moved or created or copied, Drupal to Drupal, etc.). So I'm sure I've just made errors in adapting the guidance.

Ideas on how to do to it right or understand what's wrong? If a solution preventing the phantom file-usage items can't be found, am I probably safe removing these from the file_usage table and acting like it never happened?

I'm also seeing this error intermittently. I don't know if it's related. Since the mysql seems to work fine, I've been assuming it has something to do with using a csv rather than database source?

[error] Message: Failed to connect to your database server. The server reports the following message: /No database connection configured for source plugin variable/. * Is the database server running? * Does the database exist, and have you entered the correct database name? * Have you entered the correct username and password? * Have you entered the correct database hostname?

pe flag
เงื่อนงำว่า generic.png มาจากไหน แม้ว่าฉันยังไม่รู้ว่าอาจช่วยได้: https://www.drupal.org/project/drupal/issues/3060509
Score:0
ธง pe

ฉันเชื่อว่านี่เป็นพฤติกรรมปกติ ระบบสื่อใช้ภาพขนาดย่อ และภาพขนาดย่อนับเป็นการใช้ไฟล์ ผลลัพธ์คือหากสื่อที่นำเข้าเป็นเอกสาร ภาพขนาดย่อของเอกสารทั่วไปจะถูกใช้ครั้งเดียวสำหรับแต่ละรายการที่นำเข้า

หากสื่อที่นำเข้าเป็นภาพ ภาพขนาดย่อทั่วไปจะไม่ใช้เนื่องจากไฟล์ภาพถูกใช้ดังนั้น คอลัมน์ use ในรายการ admin/content/files จะแสดง 2 การใช้งานสำหรับภาพที่นำเข้าแต่ละภาพ (สมมติว่ายังไม่มีเนื้อหาอื่นที่ใช้อยู่)

การลบการใช้งานออกจากตาราง file_usage (ใน mysql) ดูเหมือนจะไม่เสียหายอะไร แต่การปล่อยให้พวกเขาอยู่ที่นั่นก็ดูเหมือนจะไม่เสียหายอะไรเช่นกัน

โพสต์คำตอบ

คนส่วนใหญ่ไม่เข้าใจว่าการถามคำถามมากมายจะปลดล็อกการเรียนรู้และปรับปรุงความสัมพันธ์ระหว่างบุคคล ตัวอย่างเช่น ในการศึกษาของ Alison แม้ว่าผู้คนจะจำได้อย่างแม่นยำว่ามีคำถามกี่ข้อที่ถูกถามในการสนทนา แต่พวกเขาไม่เข้าใจความเชื่อมโยงระหว่างคำถามและความชอบ จากการศึกษาทั้ง 4 เรื่องที่ผู้เข้าร่วมมีส่วนร่วมในการสนทนาด้วยตนเองหรืออ่านบันทึกการสนทนาของผู้อื่น ผู้คนมักไม่ตระหนักว่าการถามคำถามจะมีอิทธิพลหรือมีอิทธิพลต่อระดับมิตรภาพระหว่างผู้สนทนา