Skip to content

Commit

Permalink
feat(farmService): run migrations after install and update
Browse files Browse the repository at this point in the history
  • Loading branch information
mrflos committed Dec 10, 2024
1 parent ab404f5 commit 9e69d0a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions services/FarmService.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ function ($tableName) use ($link, $prefix) {
$this->wiki->Query('UPDATE `' . $prefix . '__pages` SET body=CONCAT(body, "' . $this->wiki->config['yeswiki-farm-options'][$option]['content'] . '") WHERE tag="' . $this->wiki->config['yeswiki-farm-options'][$option]['page'] . '" AND latest="Y";');
}
}

$this->runMigrations($destfolder);
} else {
throw new \Exception('Le dossier ' . $this->wiki->config['yeswiki-farm-root-folder'] . ' n\'est pas accessible en écriture');
}
Expand All @@ -598,6 +600,19 @@ function ($tableName) use ($link, $prefix) {
}
}

private function runMigrations($wikiFolder)
{
// we launch migrations if wiki has the feature
if (file_exists($wikiFolder . 'tools/autoupdate/services/MigrationService.php')) {
// ensure yeswicli is executable
chmod($wikiFolder . 'yeswicli', 0755);
$currentDir = getcwd();
chdir($wikiFolder);
exec('./yeswicli migrate');
chdir($currentDir);
}
}

private function resetSQLTransactionWhenError($link, $notExistingTables, $prefix)
{
mysqli_rollback($link);
Expand Down Expand Up @@ -683,8 +698,7 @@ public function updateWiki($wiki)
$config->write();

// execute post update
$output .= 'cd ' . $destfolder . ';chmod +x tools/autoupdate/commands/console;tools/autoupdate/commands/console update:postupdate 2>&1';
$output .= shell_exec('cd ' . $destfolder . ';chmod +x tools/autoupdate/commands/console;tools/autoupdate/commands/console update:postupdate 2>&1');
$this->runMigrations($destfolder);

$output .= '<div class="alert alert-success">' . _t('FERME_WIKI') . $wiki . _t('FERME_UPDATED') . '</div>';

Expand Down

0 comments on commit 9e69d0a

Please sign in to comment.