/** * * User: Martin Donnelly * Date: 2016-04-04 * Time: 14:46 * */ var db = require('./server/units/db-connector').dbConnection; var dbAccount = require('./server/units/db-accounts')(db); var exec = require('child_process').exec; function addUsers() { 'use strict'; dbAccount.addNewAccount({ username: 'Martin ', password: 'MPReoa43', email: 'martind2000@gmail.com' }) .then(function(data) { console.log(data); dbAccount.addNewAccount({ username: 'Default', password: 'password', email: 'm@g.com' }) .then(function(data) { console.log(data); return 'DONE'; }) .catch(function(err) { console.error(err); return -1; }); }) .catch(function(err) { console.error(err); return -1; }); } function prepare_db() { exec('psql -Upostgres -d oBrand -h localhost -f ./obrand.sql', function(err) { if (err !== null) { console.log('exec error: ' + err); return -1; } else { addUsers(); } }); } function createDB() { 'use strict'; exec('createdb -Upostgres -h localhost oBrand', function(err) { if (err !== null) { console.log('exec error: ' + err); return -1; } else { prepare_db(); } }); } createDB();