Copying Custom Fields and layouts between Suite Installs

If I create need custom fields for a module, is it possible to copy all those changes over to a completely different installation of Suite? If so, what needs to be copied?

If possible, my first guess would be:

  1. The table structure (not the data) of the _cstm table for that module.
  2. Copy the fields_meta_data table
  3. Copy the custom/modules/{module name}/Ext/Vardefs/vardefs.ext.php

Anything else?

What about if I want to copy layouts, such as the Case module edit and detail view layouts? What files would I need to copy?

To copy just a new table structure to a pre-existing table, this is what I assume is how to do it:

A phpmyadmin variant would be to export the table’s structure only (Export->Custom->Choose “Structure”). After that, you will get something like this in the exported SQL file:

id int(10) NOT NULL,
name varchar(50) DEFAULT NULL

At that point, you can go ahead and remove the last line of the query and the parenthesis after the CREATE TABLE. Then, go ahead and substitute the [other_table] name and change the query to match the following:

ALTER TABLE [other_table]
ADD id int(10) NOT NULL,
ADD name varchar(50) DEFAULT NULL;

Notice how all I did was change CREATE to ALTER and add ADD before each field.

This is obviously not an example specific to Suite. In case of suite, you would also delete all the fields that are pre-existing and only leave the new fields (that would be at the end of the list.)

I can answer the second part of my own question (I think), duh, because I think I’ve done it before. The layout definition files to copy would just be one file in the custom/modules/{module name}/metadata directory. I don’t think anything else needs to be copied right for layout defs?

There is a buit-in feature to export all customisations made in Studio.

Go to Admin -> Studio
In the main page of Studio you will see at the top a button saying “Export Customisations”.

That’s a convenient feature but it exports all customizations for the module including all files in the custom/modules/{module name} folder which some of the customizations within a module I may not want to copy over. But still good to know.
It is a great tool to discover that my list of files to copy for custom fields was incomplete as you also need to copy the php file for that specific field in the ext/vardefs folder. I think I can use this export for the custom fields and just remove the custom layouts I don’t want to copy over.

You’re supposed to be able to do it in a much simpler way. You shouldn’t need to bring in the stuff from the database (_cstm and fields_meta_data). If you just bring the custom dir, the vardefs will be there, and the next QR&R should offer to make the database structure match that, and create everything for you.