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).
SELECT * FROM crosstab( 'select field_name::text, bundle::text, ''X''::text as hasfield from field_config_instance where bundle in ( ''article'', ''page'', ''blog'' ) 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)