Migrating Drupal Data: Field & Entity Crosstab

I wanted to do some migrating of field data from one site to another.  I had a ton of fields attached to a number of content types and wanted a fast way to check which fields and data were needed to move.

  • Install “tablefunc” contrib module for PostgreSQL
  • Create a crosstab query for the desired content types that I wanteed (this would work for nodes as well as custom entities).
 FROM crosstab(
   'select field_name::text, bundle::text, ''X''::text as hasfield
   from field_config_instance
   where bundle in ( 
   order by 1'
 AS ct(row_name text, article text, page text, blog text)

The output was as follows:

 row_name    | article | page | blog
 body        | X       | X    | X
 field_image | X       |      |
 field_tags  | X       |      |
 group_group | X       |      |
(4 rows)



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s