We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    Reading through Bob’s Guides for Custom Database Tables (http://www.bobsguides.com/custom-db-tables.html). The tutorial "assumes that you’ve imported your custom tables into the MODx database."

    I’m just wondering what the pros/cons/need-to-knows are regarding adding tables directly to the MODx Revolution database rather than putting them in a different database.

    A ’pro’, obviously, is that you can access them directly without needing to create a new instance of xPDO.

    Are there any compelling arguments *against* doing it though?

    Is there any need to be concerned about losing the custom tables on upgrading MODx? Or anything else that one should keep in mind when adding tables to the db?

      • 4971
      • 964 Posts
      I think Bob suggests using a different DB prefix to avoid loosing it on an upgrade.
      I did it that way and everything went OK on the 2.0.4 upgrade...
      Those are my 2 cents so far... I have not had any side effects yet.
        Website: www.mercologia.com
        MODX Revo Tutorials:  www.modxperience.com

        MODX Professional Partner
        • 28215
        • 4,149 Posts
        As long as you’re not naming the tables things like ’modx_templatevars’ or ’modx_access_actions’ or ’modx_dashboard_items’ and such, you’ll be fine and MODx wont mess with your tables.

        I almost always prefix them so it comes out like this: ’modx_quip_comments’, ’modx_gallery_items’, ’modx_discuss_posts’, etc. That prevents collisions, since the MODx core is never going to make a table with ’quip’ or ’discuss’ in the table name.

        The problem with specifying a table prefix in addPackage and in your schema is that it prevents you from having 2 MODx installs in 1 database with that custom table prefix (unless they’re sharing data).
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 3749
          • 24,544 Posts
          The main reason I suggested a different table prefix for them is that it makes it easy to generate the schema from the tables (without generating the entire MODx schema). I assumed that some people were more familiar with creating tables in PhpMyAdmin than they were with XML schemas and would prefer to do it that way for simple stand-alone tables.

          If you’re creating the schema manually, using the same table prefix should be fine as long as the full table names are unique.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 22303 MODX Staff
            • 10,725 Posts
            The key point is consistency. If someone is running two MODx installs with different table_prefixes on the same database, wouldn’t it make sense to make sure all the 3rd party components are using the table_prefix of the MODx installation they are installed in? Otherwise, you could have conflicts between third party add-ons.