How do you migrate CCK fields between environments in Drupal?

拟墨画扇 提交于 2019-12-21 05:44:09

问题


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.


回答1:


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'.




回答2:


It is not that mature yet but the features module will allow you to do this. It packages up CCK fields (among other things) into drupal modules which you can distribute.




回答3:


I personally use the Node Export module + Node Export File module (included, for CCK /image fields).

The entire node is exported into a textarea, as an associative array. The import form is similar: you paste the node array into a textarea. These processes are implemented as node operations, so they can be done in bulk (on the /admin/content/node page, or in your custom deployment module).

The benefit of this process is that you can modify the node data in transit.

Using a text editor, you can change the content type, title, add/remove/modify fields, whatever you want. Using a text editor with good find/replace, you can mass-edit hundreds of nodes. Since you have text, you can probably do all the things on your requirements list using existing tools or quickie scripts.



来源:https://stackoverflow.com/questions/1528139/how-do-you-migrate-cck-fields-between-environments-in-drupal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!