Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ language: node_js
node_js: "6"
addons:
firefox: latest
postgresql: '9.4'
install:
- npm install
before_install:
- 'export DISPLAY=:99.0'
- sh -e /etc/init.d/xvfb start
- "psql -c 'create database bitballs;' -U postgres"
before_deploy:
- 'git config --global user.email "[email protected]"'
- 'git config --global user.name "bitballs deploy bot"'
Expand Down
6 changes: 5 additions & 1 deletion database.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"dev": "postgres://localhost:5432/bitballs",
"dev": {
"driver": "sqlite3",
"filename": "sqlite.db"
},
"test": "postgres://localhost:5432/bitballs",
"prod": {
"ENV": "DATABASE_URL",
"driver": "pg"
Expand Down
2 changes: 1 addition & 1 deletion migrations/20150801045523-players.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exports.up = function(db, callback) {
db.createTable('players', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
name: 'string',
name: { type: 'string', notNull: true },
weight: 'int',
height: 'int',
birthday: 'date',
Expand Down
9 changes: 5 additions & 4 deletions migrations/20150804053921-add-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.up = function(db, callback) {
async.series([
db.createTable.bind(db, 'tournaments', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
date: 'date'
date: { type: 'date', notNull: true },
}),
db.createTable.bind(db, 'teams', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
Expand All @@ -22,13 +22,15 @@ exports.up = function(db, callback) {
round: 'string',
court: 'string',
videoUrl: 'string',
homeTeamId: 'string',
awayTeamId: 'string'
homeTeamId: 'int',
awayTeamId: 'int'
}),
db.createTable.bind(db, 'stats', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
gameId: 'int',
playerId: 'int',
time: { type: 'int' },
value: {type: 'int'},
type: 'string'
})
], callback);
Expand All @@ -42,4 +44,3 @@ exports.down = function(db, callback) {
db.dropTable.bind(db, 'stats')
], callback);
};

15 changes: 0 additions & 15 deletions migrations/20150809023413-add-stats-time.js

This file was deleted.

11 changes: 10 additions & 1 deletion migrations/20150816063154-add-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ exports.up = function(db, callback) {
db.createTable('users', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
name: 'string',
password: 'string',
password: { type: 'string', notNull: true },
email: {type: 'string', unique: true},
verificationHash: {
type: "string",
length: 100
},
verified: {
type: "boolean",
notNull: true,
defaultValue: false
},
isAdmin: 'boolean'
}, callback);
};
Expand Down
31 changes: 0 additions & 31 deletions migrations/20160301185116-required-fields.js

This file was deleted.

24 changes: 0 additions & 24 deletions migrations/20160307152540-validate-emails.js

This file was deleted.

21 changes: 0 additions & 21 deletions migrations/20160313205522-team-ints.js

This file was deleted.

12 changes: 11 additions & 1 deletion models/bookshelf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ var connectionString = typeof dbEnvironmentConfig === 'string' ?
dbEnvironmentConfig :
process.env[dbEnvironmentConfig.ENV];

if (typeof dbEnvironmentConfig.filename === 'string') {
connectionString = {
filename: dbEnvironmentConfig.filename
};
// Creates the database if needed
var driver = require(dbEnvironmentConfig.driver).verbose();
new driver.Database(dbEnvironmentConfig.filename);
}


var knex = require('knex')({
client: 'pg',
client: dbEnvironmentConfig.driver,
connection: connectionString
});

Expand Down