ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Consolidating Channel Field Groups

May 28, 2012 4:49am

Subscribe [3]
  • #1 / May 28, 2012 4:49am

    Nutmeg

    111 posts

    While building a site and changing it’s architecture we’ve noticed that certain Channel Field Groups overlap several channels. Is there a method to change a channels’ Channel Field Group without losing the entries (about 40+)?  and what would be the process?


    This would be great if possible as this would remove quit some additional custom field queries….

  • #2 / May 28, 2012 10:40am

    mark186282

    290 posts

    *** ALWAYS MAKE A BACKUP BEFORE MAKING ANY CHANGES ***

    With that said, you can change the assigned custom field group to a channel without any data loss, and you can also change it back if you change your mind.

    One of the more curious things about EE is the architecture of the channel data:

    Each entry has (at least) two records in the system:

    channel_title record
    channel_data record

    The channel_title record contains the meta data about the entry (who is the author, when was it entered, what is the status, what channel does it belong to, etc etc)

    Interestingly, the channel_data record contains one column for EVERY custom field in the system.  That means that if you have two channels:  one with 200 custom fields, and one channel with 5 custom fields… EVERY SINGLE RECORD in the system will have 205 columns (actually, there’s a formatting column for each custom column… so you’ll be dealing with more than 410 columns of information).  The data being stored is dependent on which custom field group is currently assigned to that channel.

    Changing the custom field group for a channel doesn’t change the 205 columns at all.  It just modifies the configuration of the channel to say, “when working with this channel, only deal with the columns that are defined in this custom field group”

    *** ALWAYS MAKE A BACKUP BEFORE MAKING ANY CHANGES ***

  • #3 / May 28, 2012 4:33pm

    Nutmeg

    111 posts

    Thanks Mark that’s good news. Any suggestions how to retrieve the data in the columns which are linked to the “old” custom field and port these into the columns for the new custom field? Not wearing a MSQL hat:-)

  • #4 / Jun 15, 2012 3:12am

    Nutmeg

    111 posts

    Might there be a commercial add-on which could solve this?

  • #5 / Jun 15, 2012 4:55am

    mark186282

    290 posts

    it seems that the instructions I posted have been deleted(?)

    I don’t know of any third-party program to take care of this, because of the rarity.

    I’m glad to help transfer old data to new data

  • #6 / Jun 18, 2012 10:14pm

    Nutmeg

    111 posts

    Thanks Mark, would you mind posting the instructions again, so I can test this on my local dev? Much appreciate the offer, thanks!

    PS: PM-ed you last week but that also seems to have been deleted…

  • #7 / Dec 07, 2012 3:37pm

    Envision

    18 posts

    Mark, was your solution re-posted?

    We are also looking for this solution.

    Thanks!

  • #8 / Dec 07, 2012 4:11pm

    mark186282

    290 posts

    Hello Envision!

    the best thing to do is start with a document, and make sure you have everything about the following written down:

    example:

    NEW config

    old_first_name = field_id_1
    old_last_name = field_id_2
    old_company_name = field_id_3

    NEW config

    new_first_name = field_id_77
    new_last_name = field_id_78
    new_company_name = field_id_79

    make sense so far?

    both are in channel_id = 3

    (all of the above are totally made-up assumptions)

    AFTER YOU MAKE A BACKUP!!!!

    UPDATE
         exp_channel_data
    SET
         field_id_77 = field_id_1,
         field_ft_77 = field_ft_1,
         field_id_78 = field_id_2,
         field_ft_78 = field_ft_2,
         field_id_79 = field_id_3,
         field_ft_79 = field_ft_3
    WHERE
         channel_id = 3

    this will take all of the contents from the OLD and put them in the NEW fields.

    Here’s some things to watch out for (and possibly trap for)

    1.  if there is data or formatting set in the NEW set of fields (77-79) before you run the update… IT WILL BE LOST IF YOU RUN THE UPDATE

    1b.  make sure the OLD fields and the NEW fields have the same formatting settings.

    2.  Make sure you download and backup your database before you do anything vaguely similar to this…

    3.  If you break it… it’s your fault.  that’s why you backed it up before taking my advice.  😉

    let me know your results!
    -Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases