       async.series [
         (cb) -> db.run "CREATE TABLE metadata (key TEXT PRIMARY KEY, value TEXT)", cb
         (cb) -> db.run "CREATE TABLE factoids (key TEXT PRIMARY KEY, value TEXT, last_edit TEXT)", cb
+        (cb) -> db.run "CREATE TABLE karma (key TEXT PRIMARY KEY, value INTEGER)", cb
         (cb) -> db.run "INSERT INTO metadata VALUES($key, $value)", {$key: key, $value: value}, cb
         (cb) -> db.run "INSERT INTO metadata VALUES('direct', 'no')", cb
         (cb) -> db.run "INSERT INTO metadata VALUES('ambient', 'yes')", cb

        update key, value

      else if current and isAppending
        value = "#{current} or #{value}"
        update key, value

      else if current == value

    log.info "Set factoid key #{key} for team #{team}"
    return cb null

getKarma = (team, key, cb) ->
  db = getDatabase team
  if not db? then return cb "Couldn't get database for team #{team}"

  db.get "SELECT value FROM karma WHERE key = $key", {$key: key}, (err, row) ->
    if err then return cb "Couldn't get karma for team #{team}: #{err}"
    return cb null, row?.value or null

setKarma = (team, key, value, cb) ->
  db = getDatabase team
  if not db? then return cb "Couldn't get database for team #{team}"

  db.run "INSERT OR REPLACE INTO karma VALUES($key, $value)", {$key: key, $value: value}, (err) ->
    if err then return cb "Couldn't update karma for team #{team}: #{err}"
    log.info "Set factoid key #{key} for team #{team}"
    return cb null


# BOTS ---------------------------------------------------------------------#{{{1

