I'm writing a migrator for a now-unsupported WordPress plugin that used a single "attachments" table to store data ranging from thumbnails to musical genres. It looks like this:
mysql> describe attachment;
+----------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+----------------+
| attachment_id | mediumint(7) | NO | PRI | NULL | auto_increment |
| attachment_target | varchar(32) | YES | | NULL | |
| attachment_target_id | mediumint(7) | YES | | 0 | |
| attachment_type | varchar(32) | YES | | NULL | |
| attachment_info | text | YES | | NULL | |
+----------------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
attachment_id
is just an ID, attachment_target_id
will correspond to a NID from the "artist" content type I'm trying to import this into, attachment_type
is either "genre" or "thumbnail" and attachment_info
is the actual data contained in the row ("Disco", as an example for a genre.).
To import all the genres into a taxonomy field, it seems I would extend the class that imports all the artists from the other table, then using $this->systemOfRecord = Migration::DESTINATION
, import each row into the existing nodes. Alas, given each row would be a new migration item, it seems this would overwrite the values.
I've also thought about adding a sub-query to my initial artist migration that returns a comma-separated list of genres; alas, I'm not sure how I'd do that with Drupal database abstraction layer.
Any help? Thanks!