+ if (isset($options["update-schema"])) {
+ Debug::log("checking for updates (" . DB_TYPE . ")...");
+
+ $updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION);
+
+ if ($updater->isUpdateRequired()) {
+ Debug::log("schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION);
+ Debug::log("WARNING: please backup your database before continuing.");
+ Debug::log("Type 'yes' to continue.");
+
+ if (read_stdin() != 'yes')
+ exit;
+
+ for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
+ Debug::log("performing update up to version $i...");
+
+ $result = $updater->performUpdateTo($i, false);
+
+ Debug::log($result ? "OK!" : "FAILED!");
+
+ if (!$result) return;
+
+ }
+ } else {
+ Debug::log("update not required.");
+ }
+
+ }
+
+ if (isset($options["gen-search-idx"])) {
+ echo "Generating search index (stemming set to English)...\n";
+
+ $res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL");
+ $row = $res->fetch();
+ $count = $row['count'];
+
+ print "Articles to process: $count.\n";