diff options
author | Ben Burwell <ben@benburwell.com> | 2015-08-02 20:32:51 -0400 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2015-08-02 20:32:51 -0400 |
commit | 68c62d41d2b77f4aa9dbb177e47acf6caa369074 (patch) | |
tree | b565673aa67fa48d54a6eed31c29d6e884a33d0a /db | |
parent | 3c36ceb95b9bf3119c37d34d64559f89f3056618 (diff) |
let's see if we can get Heroku to create the schema for us
Diffstat (limited to 'db')
-rw-r--r-- | db/bootstrap.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/bootstrap.js b/db/bootstrap.js new file mode 100644 index 0000000..009211f --- /dev/null +++ b/db/bootstrap.js @@ -0,0 +1,23 @@ +var pg = require('pg'); +var fs = require('fs'); + +pg.connect(process.env.DATABASE_URL, function(err, client, done) { + if (err) { + return console.error('Unable to connect to datbase', err); + } + + fs.readFile('schema.sql', function(err, sql) { + if (err) { + return console.error('Unable to read SQL file', err); + } + + client.query(sql, function(err) { + if (err) { + return console.error('Error running SQL query', err); + } + + console.log('Database created'); + done(); + }); + }); +}); |