knex db interface
replace raw queries with knex and thenables
knexify more sql functions
Merge branch 'dev'

Conflicts:
	lib/routes/testcases.js