A data engineering quest: Drupal To WordPress

A Data Engineering quest: 

Migration of information from Drupal to WordPress require an abstraction effort as well knowledge of both databases schema . The Drupal Database logic is slightly different and “Node Oriented” Design.

Schema:

 

Schema Logic:

In a data driven approach , the table Node is  the main table.  The actor in this table ( and primary key ) is the Entity with it’s numeric ID and different Type depending on the type of the entity.

Node_revision  table , like the other revision tables , dedicate to maintain the history of changes to that entity.

As the schema is normalised , using the ID of the entity , you can get the following data ( in logic order) :

Table  node:

  • title
  • id
  • uid
  • name

Table users:

  • name

Table field_data_field_image using id:

  • field_image_id
  • field_image_title
  • field_image_alt

Table file_managed:

  • uri

Table field_data_body:

  • body_value
  • body_summary

Table field_data_field_category_new:

  • field_category_new_tid

Table taxonomy_term_data:

  • name
  • description

Table metatag

  • data

Example: 

Let’s suppose we would like to migrate the information of a particular entity type called “news” .

We will obtain the list of IDs of this entity type with status published:

SELECT `nid` FROM `node` WHERE `type` = ‘{$posttype}’ and `status` = 1

Collect the entity title and user id:

SELECT `title` FROM `node` WHERE `nid` = ‘{$id}'”

SELECT `uid` FROM `node` WHERE `nid` = ‘{$id}'”

Obtain name of the user:

SELECT `name` FROM `users` WHERE `uid` = ‘{$id}'”

Collect the image attached to the entity and it’s meta data:

SELECT `field_image_fid` FROM `field_data_field_image` WHERE `entity_id` = ‘{$id}'”

field_image_title` FROM `field_data_field_image` WHERE `entity_id` = ‘{$id}'”

SELECT `field_image_alt` FROM `field_data_field_image` WHERE `entity_id` = ‘{$id}'”

SELECT `uri` FROM `file_managed` WHERE `fid` = ‘{$fid}'”

Collect the entity body, summary and category:

SELECT `body_value` FROM `field_data_body` WHERE `entity_id` = ‘{$id}'”

SELECT `body_summary` FROM `field_data_body` WHERE `entity_id` = ‘{$id}'”

SELECT `field_category_new_tid` FROM `field_data_field_category_new` WHERE `entity_id` = ‘{$id}'”

Get the category name :

SELECT `name` FROM `taxonomy_term_data` WHERE `tid` = ‘{$tid}'”

SELECT `description` FROM `taxonomy_term_data` WHERE `tid` = ‘{$tid}'”

And finally the SEO metadata:

SELECT CONVERT(`data` USING utf8) FROM `metatag` where `entity_id` = ‘{$id}'”

 

 

 

Check also my other devs guides :  How to build your blockchain 

Hope it helps! 🙂