Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2022-02-07 00:50:04 +0300
committerThomas Bruederli <thomas@roundcube.net>2022-02-07 00:50:04 +0300
commitcc1c3c41b08d9f095abf4e324ba14bd7fa35fe50 (patch)
tree20bd59aa858822095126cd88a46619d807b59413
parenta482ff79e724b9d21a6f517a45fe6ae1305bd1fd (diff)
Add option in initdb.sh to update schema if already existspr-initdb-update
This can be used by the Docker images where we don't know whether the configured database is already initialized or not.
-rwxr-xr-xbin/initdb.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/initdb.sh b/bin/initdb.sh
index acff3121c..a98bbf53a 100755
--- a/bin/initdb.sh
+++ b/bin/initdb.sh
@@ -25,6 +25,7 @@ require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt([
'd' => 'dir',
+ 'u' => 'update'
]);
if (empty($opts['dir'])) {
@@ -36,4 +37,11 @@ if (!file_exists($opts['dir'])) {
rcube::raise_error("Specified database schema directory doesn't exist.", false, true);
}
-rcmail_utils::db_init($opts['dir']);
+$db = rcmail_utils::db();
+
+if (!empty($opts['update']) && in_array($db->table_name('system'), (array)$db->list_tables())) {
+ echo "Checking for database schema updates..." . PHP_EOL;
+ rcmail_utils::db_update($opts['dir'], 'roundcube', null, ['errors' => true]);
+} else {
+ rcmail_utils::db_init($opts['dir']);
+}