/** * Fix Db Schema version in the db * @since 20130929 */ private function fixDbSchema() { require JPATH_ADMINISTRATOR . '/components/com_installer/models/database.php'; $model = new InstallerModelDatabase(); $model->fix(); $changeSet = $model->getItems(); bfEncrypt::reply('success', array('latest' => $changeSet->getSchema(), 'current' => $model->getSchemaVersion(), 'schema_errors' => $model->getItems()->check())); }
/** * Make sure the db schema is updated - even Akeeba doesnt do this :-) */ public function finishup() { require 'bfInitJoomla.php'; jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); // Because of the crappy Joomla early days of updates in 3.1.0 $sql = "CREATE TABLE IF NOT EXISTS `#__content_types` (\n `type_id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `type_title` varchar(255) NOT NULL DEFAULT '',\n `type_alias` varchar(255) NOT NULL DEFAULT '',\n `table` varchar(255) NOT NULL DEFAULT '',\n `rules` text NOT NULL,\n `field_mappings` text NOT NULL,\n `router` varchar(255) NOT NULL DEFAULT '',\n PRIMARY KEY (`type_id`),\n KEY `idx_alias` (`type_alias`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10000;"; $db = JFactory::getDbo(); $db->setQuery($sql); if (method_exists($db, 'execute')) { $db->execute(); } else { $db->query(); } // Let Joomla handle the grunt work $filePath = JPATH_ROOT . '/administrator/components/com_admin/script.php'; if (file_exists($filePath)) { require_once $filePath; $o = new JoomlaInstallerScript(); if (method_exists($o, 'preflight')) { $o->preflight('update', NULL); } if (method_exists($o, 'update')) { $o->update(NULL); } // need to upgrade db as well. require JPATH_ROOT . '/administrator/components/com_installer/models/database.php'; $model = new InstallerModelDatabase(); $model->fix(); } bfEncrypt::reply('success', array('msg' => json_encode(true))); }