mirror of
https://gitlab.silvrtree.co.uk/martind2000/mdot_mqtt.git
synced 2025-01-10 20:45:08 +00:00
39 lines
613 B
JavaScript
39 lines
613 B
JavaScript
/**
|
|
*
|
|
* User: Martin Donnelly
|
|
* Date: 2016-04-04
|
|
* Time: 14:46
|
|
*
|
|
*/
|
|
var exec = require('child_process').exec;
|
|
|
|
|
|
function prepare_db() {
|
|
exec('psql -Upostgres -h localhost -f ./mdot.sql', function(err) {
|
|
if (err !== null) {
|
|
console.log('exec error: ' + err);
|
|
return -1;
|
|
} else {
|
|
console.log('Done?');
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function createDB() {
|
|
'use strict';
|
|
exec('createdb -Upostgres -h localhost mdot', function(err) {
|
|
if (err !== null) {
|
|
console.log('exec error: ' + err);
|
|
return -1;
|
|
} else {
|
|
prepare_db();
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
prepare_db();
|