mirror of
https://gitlab.silvrtree.co.uk/martind2000/obrand-admin-server.git
synced 2025-01-10 21:05:09 +00:00
75 lines
1.3 KiB
JavaScript
75 lines
1.3 KiB
JavaScript
/**
|
|
*
|
|
* 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();
|