(Tutorial) Moving CCK Field Changes from Dev to Live
Tutorial: Moving CCK Field Changes from Dev to Live
This article applies to Drupal 5 and higher.
If you're the maintainer of a even a small site using CCK for managing your information, eventually you'll run into a problem synchronzing your local install with your live site (or Dev and QA servers). While setting up CCK fields is a breeze and you have SVN to manage your PHP code, many Drupal developers haven't found a way to easily migrate changes in the CCK data schema or content type fields. However, using the handy macro module and a few (very important) lines of custom code, you can be moving your field changes from Dev to live in seconds.
To clarify the task at hand, say you have a content type called "article". The article type contains 3 fields at the moment: Title, Body, and Picture. The problem is, your site is about to undergo a major overhaul where articles now contain Title, Excerpt, Body, Picture, Caption, Small Picture, and Related Links. Additionally, your boss wants them seperated into different field groups to make it easier to handle the more complex form.
Here's what we want our article content type fields to look like, before and after.
Before overhaul:
Our updated content type:
This article assumes you've already made your changes to your PHP code and have them ready to deploy through SVN, but you don't want to have to setup the changes to the content type manually on the dev server, qa server, live server, and potentially several of your coworkers' computers manually.
drupal_execute and Macro module
Fortunately, Drupal has a convient mechanism for being able to execute any form programatically. It's called drupal_execute(). Though often over-hyped and under-utlized, drupal_execute() can save us tremendous amounts of work. Drupal execute takes two arguments, the name of the form to execute, and an array of values to pass into the form.
Continuing down the list of cool things Drupal gives you, if you've downloaded and installed Devel module, it comes with a bundled module called Macro. Macro has the ability to record all your form submissions, then play them all back on different servers.
Courtesy : Lullabot.com
- guru's blog
- Login to post comments



![Drupal-6-Book-[Building Powerful and Robust Websites with Drupal 6].jpg](http://www.drupalranch.com/images/Drupal-6-Book-[Building%20Powerful%20and%20Robust%20Websites%20with%20Drupal%206].jpg)