<commit_before>
var models = require('../')
  , async = require('async')

// done(err)
module.exports = {
  ensure: ensure,
  isNeeded: isNeeded,
  upgrade: upgrade
}

var upgrades = {
  0: require('./from0to1')
}

function ensure(version, done) {
  isNeeded(version, function (err, needed, oldv, newv) {
    if (err) return done(err)
    if (!needed) return done()
    console.log('Updating database from version %d to %d', oldv, newv)
    upgrade(oldv, newv, done)
  })<commit_msg>be careful to warn people before automatically upgrading their db we need to give people a chance to backup!<commit_after>
var models = require('../')
  , async = require('async')

// done(err)
module.exports = {
  ensure: ensure,
  isNeeded: isNeeded,
  upgrade: upgrade
}

var upgrades = {
  0: require('./from0to1')
}

function ensure(version, done) {
  isNeeded(version, function (err, needed, oldv, newv) {
    if (err) return done(err)
    if (!needed) return done()
    if (process.env.STRIDER_DB_UPGRADE !== 'yes') {
      console.log("Your Strider database needs to be upgraded.")
      console.log("Please make sure you take a backup and then re-run with environment variable STRIDER_DB_UPGRADE=yes")
    } else {
      console.log("STRIDER_DB_UPGRADE is set to yes")
      console.log('Updating database from version %d to %d', oldv, newv)
      upgrade(oldv, newv, done)
    }
  })
{'fraction_non_alphanumeric': 0.13372093023255813, 'fraction_numerical': 0.00436046511627907, 'mean_word_length': 3.6363636363636362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1433760', 'n_tokens_mistral': 466, 'n_tokens_neox': 455, 'n_words': 142}