We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2611
    • 394 Posts
    When I do an upgrade in a transport package, what is the correct
    way to go when modifying tables? Does xPDO handle this or should
    we manually export the data, drop the table, create the new structure
    and import the data?

    What is the way to go smiley

    Thanks in advance.
      Follow me on twitter: @b03tz
      Follow SCHERP Ontwikkeling on twitter: @scherpontwikkel
      CodeMaster
      • 28215
      • 4,149 Posts
      As always, check how other Extras do it. Here’s quip, with a resolver that fires on upgrade:

      if ($object->xpdo) {
          switch ($options[xPDOTransport::PACKAGE_ACTION]) {
              case xPDOTransport::ACTION_UPGRADE:
                  $modx =& $object->xpdo;
                  $modelPath = $modx->getOption('quip.core_path',null,$modx->getOption('core_path').'components/quip/').'model/';
                  $modx->addPackage('quip',$modelPath);
      
                  /* add name,email,website fields */
                  $modx->exec("ALTER TABLE {$modx->getTableName('quipComment')} ADD `name` VARCHAR(255) NOT NULL default ''");
                  $modx->exec("ALTER TABLE {$modx->getTableName('quipComment')} ADD `email` VARCHAR(255) NOT NULL default ''");
                  $modx->exec("ALTER TABLE {$modx->getTableName('quipComment')} ADD `website` VARCHAR(255) NOT NULL default ''");
      
                  /* more stuff ...*/
                  break;
          }
      }
      return true;
      
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 2611
        • 394 Posts
        Thanks alot! Why did I not think of that...looking at other components *stupid stupid me*.
          Follow me on twitter: @b03tz
          Follow SCHERP Ontwikkeling on twitter: @scherpontwikkel
          CodeMaster