<commit_before>var Bookshelf = require('bookshelf');

var db = Bookshelf.initialize({
  client: 'sqlite3',
  connection: {
    host: '127.0.0.1',
    user: 'your_database_user',
    password: 'password',
    database: 'shortlydb',
    charset: 'utf8',
    filename: path.join(__dirname, '../db/shortly.sqlite')
  }
});

db.knex.schema.hasTable('users').then(function(exists) {
  if (!exists) {
    db.knex.schema.createTable('users', function (user) {
      user.increments('id').primary();
      user.string('username', 100).unique();
      user.string('password', <PASSWORD>);
      user.string('email', 100);
      user.string('stripeId', 255);
      user.string('firstName', 100);
      user.string('lastName', 100);
      user.string('shippingAddress', 255);
      user.string('phoneNumber', 100);
      user.timestamps();
    }).then(function (table) {
      console.log('Created Table', table);
    });
  }
});

db.knex.schema.hasTable('events').then(function(exists) {
  if (!exists) {
    db.knex.schema.createTable('events', function (event) {
      event.increments('id').primary();
      event.string('title', 255);
      event.text('description');
      event.string('url', 255);
      event.string('owner', 100);
      event.dateTime('expiration');
      event.integer('thresholdPeople');
      event.integer('thresholdMoney');
      event.integer('invites');
      event.integer('committedPeople');
      event.integer('committedMoney');
      event.string('disqusKey', 255);
      event.timestamps();
    }).then(function (table) {
      console.log('Created Table', table);
    });
  }
});

db.knex.schema.hasTable('invites').then(function(exists) {
  if (!exists) {
    db.knex.schema.createTable('invites', function (invite) {
      invite.increments('id').primary();
      invite.string('user_id', 255);
      invite.string('event_id', 255);
      invite.boolean('joined');
      invite.boolean('declined');
      invite.timestamps();
    }).then(function (table) {
      console.log('Created Table', table);
    });
  }
});

module.exports = db;
<commit_msg>Set db connection to process.env.DATABASE_URL, change to standard Bookshelf/Knex format<commit_after>var Bookshelf = require('bookshelf');

var knex = require('knex')({
  client: 'pg',
  connection: process.env.DATABASE_URL
});

var db = require('bookshelf')(knex);

db.knex.schema.hasTable('users').then(function(exists) {
  if (!exists) {
    db.knex.schema.createTable('users', function (user) {
      user.increments('id').primary();
      user.string('username', 100).unique();
      user.string('password', <PASSWORD>);
      user.string('email', 100);
      user.string('stripeId', 255);
      user.string('firstName', 100);
      user.string('lastName', 100);
      user.string('shippingAddress', 255);
      user.string('phoneNumber', 100);
      user.timestamps();
    }).then(function (table) {
      console.log('Created Table', table);
    });
  }
});

db.knex.schema.hasTable('events').then(function(exists) {
  if (!exists) {
    db.knex.schema.createTable('events', function (event) {
      event.increments('id').primary();
      event.string('title', 255);
      event.text('description');
      event.string('url', 255);
      event.string('owner', 100);
      event.dateTime('expiration');
      event.integer('thresholdPeople');
      event.integer('thresholdMoney');
      event.integer('invites');
      event.integer('committedPeople');
      event.integer('committedMoney');
      event.string('disqusKey', 255);
      event.timestamps();
    }).then(function (table) {
      console.log('Created Table', table);
    });
  }
});

db.knex.schema.hasTable('invites').then(function(exists) {
  if (!exists) {
    db.knex.schema.createTable('invites', function (invite) {
      invite.increments('id').primary();
      invite.string('user_id', 255);
      invite.string('event_id', 255);
      invite.boolean('joined');
      invite.boolean('declined');
      invite.timestamps();
    }).then(function (table) {
      console.log('Created Table', table);
    });
  }
});

module.exports = db;

{'fraction_non_alphanumeric': 0.1895919863181041, 'fraction_numerical': 0.021011483019789886, 'mean_word_length': 3.46943231441048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '172932', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1291, 'n_words': 200}