<commit_before>const db = require("./db");
const Keygrip = require('keygrip');
const pgpatcher = require("pg-patcher");
const path = require("path");

const MAX_DB_LEVEL = 6;

/** Create all the tables */
exports.createTables = function () {
  console.info("Setting up tables on", db.constr);
  return db.getConnection().then(([conn, done]) => {
    // This is assuming we are running from dist/server/dbschema.js, and need to
    // find the path of server/db-patches/ (not dist):
    let dirname = path.join(__dirname, "..", "..", "server", "db-patches");
    return new Promise((resolve, reject) => {
      pgpatcher(conn, MAX_DB_LEVEL, {dir: dirname}, function(err) {
        if (err) {
          console.error(`Error patching database to level ${MAX_DB_LEVEL}!`, err);
          done();
          reject(err);
        } else {
          console.info(`Database is now at level ${MAX_DB_LEVEL}`);
          resolve();
        }
      });
    });
  }).then(() => {
    let newId = "tmp" + Date.now();
    return db.insert(
      `INSERT INTO data (id, deviceid, value, url)
       VALUES ($1, NULL, $2, $3)`,
      [newId, "test value", ""]
    ).then((inserted) => {<commit_msg>Log the environment for debugging<commit_after>const db = require("./db");
const Keygrip = require('keygrip');
const pgpatcher = require("pg-patcher");
const path = require("path");

const MAX_DB_LEVEL = 6;

/** Create all the tables */
exports.createTables = function () {
  console.info("Setting up tables on", db.constr);
  console.info("Environment: ", process.env);
  return db.getConnection().then(([conn, done]) => {
    // This is assuming we are running from dist/server/dbschema.js, and need to
    // find the path of server/db-patches/ (not dist):
    let dirname = path.join(__dirname, "..", "..", "server", "db-patches");
    return new Promise((resolve, reject) => {
      pgpatcher(conn, MAX_DB_LEVEL, {dir: dirname}, function(err) {
        if (err) {
          console.error(`Error patching database to level ${MAX_DB_LEVEL}!`, err);
          done();
          reject(err);
        } else {
          console.info(`Database is now at level ${MAX_DB_LEVEL}`);
          resolve();
        }
      });
    });
  }).then(() => {
    let newId = "tmp" + Date.now();
    return db.insert(
      `INSERT INTO data (id, deviceid, value, url)
       VALUES ($1, NULL, $2, $3)`,
      [newId, "test value", ""]
    ).then((inserted) => {
{'fraction_non_alphanumeric': 0.17504118616144976, 'fraction_numerical': 0.0032948929159802307, 'mean_word_length': 2.819182389937107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '79780', 'n_tokens_mistral': 771, 'n_tokens_neox': 755, 'n_words': 212}