Allow use of ids or names in configuration

Created on 10 December 2024, about 1 month ago

Problem/Motivation

Airtable bases have unique ids and user-friendly labels.
Each table in a base also has both a unique id and a user-friendly label.
Each field in a base also has this behavior.

For convenience, the initial version of this module only supports user-friendly labels in the base, tables and field names. I think that makes the migration configurations look lovely, but if a base name or a table name is changed, the migration will stop working, which may be unacceptable for some users.

Steps to reproduce

Create an Airtable base, "My Test Base"
Create a table in that base; "My Data"
Create columns in that table: "Thing1", "Thing2"

Create a migration:

id: things
label: "Things from Airtable" # This is a Drupal label, not affected
source:
  plugin: airtable
  base: 'My Test Base' 
  table: 'My Data'
  constants:
    uid: 1
    body_format: basic_html
destination:
  plugin: entity:node
  default_bundle: article
process:
  title: Thing1
  uid: constants/uid
  body/value: Thing2
  body/format: constants/body_format

Proposed resolution

Revist the code in Plugin/migrate/source/Airtable.php to respect either name or id for

I think it would be terrible to use a bunch of random-looking ids in the field-mapping portion of migrate, but we can support either names or ids by setting the field twice in getAirtableFields():

so, this:

          $fields[$field->name] = (array) $field;

Becomes this

          $fields[$field->name] = (array) $field;
          $fields[$field->id] = (array) $field;
✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Allie Micka

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

Comments & Activities

Production build 0.71.5 2024