<commit_before><commit_msg>started a tool to create db schemas with knex<commit_after>// get db config options from ./conf/db.js
var dbOptions;
try {
    dbOptions = require('../conf/db');
} catch(e) {
    console.log('ERROR: DB configuration is missing!');
    console.log('Please rename conf/db.js.example to conf/db.js and edit the file to your needs.');
    process.exit(1);
}

var knex = require('knex')(dbOptions);

// since knex uses connection pool, need to fake a query to check if sql if reachable
knex.raw('select 1+1 as result')
    .then(function (result) {
        // it worked... silent pass!
    })
    .catch(function (error) {
        console.log('ERROR: Could not access your database. Check the config and make sure SQL is running!');
        process.exit(1);
    });

// create tables
knex.schema.createTable('gifs', function (table) {
    table.increments();
    table.string('filename', 100);
    table.timestamp('uploaded_at');
}).then(function () {
    console.log('All tables created successfully!');
    knex.destroy();
});

{'fraction_non_alphanumeric': 0.1455756422454805, 'fraction_numerical': 0.006660323501427212, 'mean_word_length': 3.3833333333333333, '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': '5370573', 'n_tokens_mistral': 322, 'n_tokens_neox': 315, 'n_words': 101}