allow updating database schema in batch mode

master
Andrew Dolgov 4 years ago
parent 335dcd3bf9
commit 97d7e5a42a

@ -91,7 +91,7 @@
"log-level:", "log-level:",
"indexes", "indexes",
"pidlock:", "pidlock:",
"update-schema", "update-schema:",
"convert-filters", "convert-filters",
"force-update", "force-update",
"gen-search-idx", "gen-search-idx",
@ -145,7 +145,7 @@
print " --log FILE - log messages to FILE\n"; print " --log FILE - log messages to FILE\n";
print " --log-level N - log verbosity level\n"; print " --log-level N - log verbosity level\n";
print " --indexes - recreate missing schema indexes\n"; print " --indexes - recreate missing schema indexes\n";
print " --update-schema - update database schema\n"; print " --update-schema [force-yes] - update database schema (without prompting)\n";
print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n";
print " --convert-filters - convert type1 filters to type2\n"; print " --convert-filters - convert type1 filters to type2\n";
print " --send-digests - send pending email digests\n"; print " --send-digests - send pending email digests\n";
@ -412,12 +412,16 @@
else else
Debug::log("WARNING: please backup your database before continuing."); Debug::log("WARNING: please backup your database before continuing.");
Debug::log("Type 'yes' to continue."); if ($options["update-schema"] != "force-yes") {
Debug::log("Type 'yes' to continue.");
if (read_stdin() != 'yes') if (read_stdin() != 'yes')
exit; exit;
} else {
Debug::log("Proceeding to update without confirmation...");
}
Debug::log("Performing updates to version " . SCHEMA_VERSION); Debug::log("Performing updates to version " . SCHEMA_VERSION . "...");
for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
Debug::log("* Updating to version $i..."); Debug::log("* Updating to version $i...");
@ -430,10 +434,11 @@
Debug::log("One of the updates failed. Either retry the process or perform updates manually."); Debug::log("One of the updates failed. Either retry the process or perform updates manually.");
return; return;
} }
} }
Debug::log("All done.");
} else { } else {
Debug::log("Update not required."); Debug::log("Database schema is already at latest version.");
} }
} }

Loading…
Cancel
Save