We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36519
    • 40 Posts
    Hi,

    I have just created a simple 'quote of the day' display that randomly shows a quote from a set of data. This seemed to be a perfect fit for migx usage-- data is small, there are only a couple of "field" (quoted text, author and date).

    I have a few questions to ask. If I want to change the data set configuration, like adding more fields to the migx which already have some records in it, will I lose the contents? If that is the case, what is a mechanism of saving the existing data and feed them into revised migx TV?

    Sorry if this is already an answered question. Nothing showed up on my search.

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Well, a bit of trial-and-error indicates that in my case at least adding a field to a TV's configuration didn't lose anything.

      The database tables involved (unless, of course, you're using MIGXdb with custom tables) are the site_tmplvars and site_tmplvar_contentvalues tables. The relevant fields are all JSON strings. For example (I tested by first setting three sets with two fields, then adding the "date" field and editing one of them),
      [{"MIGX_id":"1","title":"Test One","date":"March 3, 2013","description":"This is the first test."},{"MIGX_id":"2","title":"Test Two","description":"This is the second test."},{"MIGX_id":"3","title":"Test Three","description":"This is the third test."}]


      As far as I am aware, there is no existing function to work with these, but it should be possible to create code to back up the content and then rewrite a new JSON string restore fields to the fields of the same name.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36519
        • 40 Posts
        Thanks, that's a good enough information for now, as I now know where to look for my migx dataset with a knowledge (or hopeful thought?) that in the event of data loss, I can go to mysql backup and pull the JSON string, then re-construct/modify the data on my local pc using [[a tool of my choice]].
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          An interesting thing that I discovered while testing this is that when re-ordering the items in the MIGx grid, it re-writes the entire JSON string to reflect the new position of the individual sets. The migx_id of each set doesn't change, nor is there any other change in the data. There is no "order" or "position" field. So the getImageList snippet simply displays each set as it appears in the whole JSON string, no need to do any further processing to decide on how to order the list.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 36519
            • 40 Posts
            Thanks for the "investigation.", I feel more comfortable using migx. I kind of expected/hoped that(JASON data structure change would not affect the data) would be the case, as I think whole migx/JSON string will be retrieved/saved every time a record is inserted/edited. I will start getting worried if the size of JSON get really big and would opt for migxDB. For the time being, I dont seeem to have a good luck with migxDB though

            https://forums.modx.com/thread/81732/migx-error-quip-thread-err-save?page=2
              • 4172
              • 5,888 Posts
              @masakia:

              Would you like to create a new thread with a complete description of your issues, which you have with MIGXdb?
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 36519
                • 40 Posts
                Quote from: Bruno17 at Apr 04, 2013, 10:54 AM
                @masakia:

                Would you like to create a new thread with a complete description of your issues, which you have with MIGXdb?

                Thanks Bruno,
                I will certainly start a new thread once I try the last suggestion on that thread link and it still wouldn't work for me.

                https://forums.modx.com/thread/81732/migx-error-quip-thread-err-save?page=2