This commit is contained in:
Paula Quispe
2017-10-09 16:19:12 -04:00
parent 958e1255a8
commit d0483f8b44
3 changed files with 243 additions and 87 deletions

View File

@@ -315,6 +315,17 @@ CLI::taskOpt("lang", "", "lLANG", "lang=LANG");
CLI::taskArg('workspace');
CLI::taskRun("cliListIds");
/**
* Upgrade the CONTENT table
*/
CLI::taskName('upgrade-content');
CLI::taskDescription(<<<EOT
Upgrade the content table
EOT
);
CLI::taskArg('workspace');
CLI::taskRun("run_upgrade_content");
/**
*
*/
@@ -375,6 +386,56 @@ function run_workspace_upgrade($args, $opts)
}
}
/**
* We will upgrade the CONTENT table
* If we apply the command for all workspaces, we will need to execute one by one by redefining the constants
* @param string $args, workspaceName that we need to apply the upgrade-content
* @param string $opts
*
* @return void
*/
function run_upgrade_content($args, $opts)
{
//Check if the command is executed by a specific workspace
if (count($args) === 1) {
upgradeContent($args, $opts);
} else {
$workspaces = get_workspaces_from_args($args);
foreach ($workspaces as $workspace) {
passthru('./processmaker upgrade-content ' . $workspace->name);
}
}
}
/**
* This function will upgrade the CONTENT table for a workspace
* This function is executed only for one workspace
* @param array $args, workspaceName that we will to apply the command
* @param array $opts, we can send additional parameters
*
* @return void
*/
function upgradeContent($args, $opts)
{
try {
//Load the attributes for the workspace
$arrayWorkspace = get_workspaces_from_args($args);
//Loop, read all the attributes related to the one workspace
$wsName = $arrayWorkspace[key($arrayWorkspace)]->name;
Bootstrap::setConstantsRelatedWs($wsName);
$workspaces = get_workspaces_from_args($args);
foreach ($workspaces as $workspace) {
try {
G::outRes("Upgrading content for " . pakeColor::colorize($workspace->name, "INFO") . "\n");
$workspace->upgradeContent($workspace->name, true);
} catch (Exception $e) {
G::outRes("Errors upgrading content of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n");
}
}
} catch (Exception $e) {
G::outRes(CLI::error($e->getMessage()) . "\n");
}
}
/**
* We will repair the translation in the languages defined in the workspace
* Verify if we need to execute an external program for each workspace