R – How to migrate CCK fields between environments in Drupal

cckdrupaldrupal-6

The Content Construction Kit (CCK) is one of the most useful Drupal modules. It allows you to easily add custom fields to a content type.

However, these new fields are created through Drupal itself and stored in the database. This means that if you change a CCK field in your development environment you need to manually make the same change in your test and production environments.

Worse, there's no simple way to determine if your environments have gotten out of sync. So if you ever inadvertantly mess up or omit a change as you put it into test or production you may never realise.

I'm looking for a technique that allows me to export CCK field definitions that supports:

  • Importing into new environments (obviously)
  • Creating new fields

Ideally the export would also support:

  • Diffing
  • Modification of existing fields
  • Deletion of existing fields
  • Some kind of conflict resolution in situations where data clashes with field changes

The simpler and more repeatable the solution the better. I would like to avoid custom scripting or GUI automation unless there is a very clean way to do this.

Best Answer

Are you aware of the Content Copy module that is part of the standard cck package? It offers export/import functionality for fields and whole content types to some extent.

It does not offer diffing by itself, and I'm not sure about how well it does modifications of already existing fields, but it helps a lot for moving new fields and/or content types.

Also, you can save the output of exports from different instances and diff them locally, which gives you a pretty good overview of changes (especially revealing 'out of sync' situations quickly).

After enabling, check the new export and import tabs on top of '/admin/content/types'.

Related Topic