<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict';

// TODO extract schema into, you know, a schema file
// TODO figure out migrations story - mysql-patcher? node-migrate?
// TODO normalize URLs and store in visits 'url' field
// TODO add to visits when addon supports it: referrer, searchTerms, engagementTime

var program = require('commander');
var utils = require('./utils');
var config = require('../config');
var log = require('../logger')('server.db');

var pool = utils.createPool(true);

function createDatabase(cb) {
  var dropDatabaseQuery = 'DROP DATABASE IF EXISTS chronicle';
  var createDatabaseQuery = 'CREATE DATABASE IF NOT EXISTS chronicle ' +
    'CHARACTER SET utf8 COLLATE utf8_unicode_ci';
  var useDatabaseQuery = 'USE chronicle';
  var createUsersTableQuery = 'CREATE TABLE IF NOT EXISTS users (' +
    'fxaId CHAR(32) NOT NULL PRIMARY KEY,' +
    'email VARCHAR(256) NOT NULL,' +
    'oauthToken VARCHAR(256),' +
    'createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,' +
    'updatedAt TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,' +
    'INDEX (email)' +
    ') ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;';<commit_msg>bug(db): shorten email field by one char to avoid mysql drama<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict';

// TODO extract schema into, you know, a schema file
// TODO figure out migrations story - mysql-patcher? node-migrate?
// TODO normalize URLs and store in visits 'url' field
// TODO add to visits when addon supports it: referrer, searchTerms, engagementTime

var program = require('commander');
var utils = require('./utils');
var config = require('../config');
var log = require('../logger')('server.db');

var pool = utils.createPool(true);

function createDatabase(cb) {
  var dropDatabaseQuery = 'DROP DATABASE IF EXISTS chronicle';
  var createDatabaseQuery = 'CREATE DATABASE IF NOT EXISTS chronicle ' +
    'CHARACTER SET utf8 COLLATE utf8_unicode_ci';
  var useDatabaseQuery = 'USE chronicle';
  var createUsersTableQuery = 'CREATE TABLE IF NOT EXISTS users (' +
    'fxaId CHAR(32) NOT NULL PRIMARY KEY,' +
    'email VARCHAR(255) NOT NULL,' +
    'oauthToken VARCHAR(256),' +
    'createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,' +
    'updatedAt TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,' +
    'INDEX (email)' +
    ') ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;';
{'fraction_non_alphanumeric': 0.10928362573099415, 'fraction_numerical': 0.011695906432748537, 'mean_word_length': 4.115887850467289, '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': '6575603', 'n_tokens_mistral': 871, 'n_tokens_neox': 819, 'n_words': 315}