// Turn version history off everywhere except workflows. // // Only two places in the codebase read a version: the workflow controller (the // editor's version picker, publish and restore) and the runner (loading the // published version to run it). Both are about workflows. Everywhere else the // history is written on every save and read by nothing - and maxVersions 0 // means unlimited, so it never stops growing. // // executions is the worst of it: 481 MB, and each run writes its record two or // three times - before the walk, on a pause, at the end - so every one of those // is kept for ever. // // Disabling stops new versions being recorded. History already written stays // readable, so this is reversible and reclaims nothing by itself. #include #include #include #include using namespace smartbotic::database; int main() { Client::Config cfg; cfg.address="192.168.2.150:9004"; cfg.project="smartbotic-automation"; Client c(cfg); if (!c.connect()) return 1; const std::vector keep = {"workflows"}; std::vector names; for (auto& n : c.listCollections()) { auto bare = n.rfind(':')==std::string::npos ? n : n.substr(n.rfind(':')+1); names.push_back(bare); } int off=0, kept=0, skipped=0; for (auto& n : names) { auto current = c.getCollectionConfig(n); bool on = current.versioningEnabled.value_or(true); bool must_keep = false; for (auto& k : keep) if (n == k) must_keep = true; if (must_keep) { printf(" %-28s left ON (its history is read)\n", n.c_str()); kept++; continue; } if (!on) { skipped++; continue; } Client::CollectionConfig want; // precision left unset, so untouched want.versioningEnabled = false; if (c.configureCollection(n, want)) { printf(" %-28s versioning off\n", n.c_str()); off++; } else printf(" %-28s FAILED\n", n.c_str()); } printf("turned off %d, left on %d, already off %d\n", off, kept, skipped); return 0; }