Last active
January 30, 2019 04:59
-
-
Save joshuacullenlux/750293e74432fff0c2d6d24a89bef509 to your computer and use it in GitHub Desktop.
migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_ENV=local node migrate.js | |
//migrate.js | |
require("dotenv-safe").config({ | |
path: ".env" | |
}); | |
const config = require("../src/config").get(); | |
const Postgrator = require("postgrator"); | |
const postgrator = new Postgrator({ | |
connectionString: config.database.url, | |
}); | |
//config.js | |
const env = require("./env"); | |
let config = null; | |
const load = () => { | |
config = env.config; | |
}; | |
exports.setConfig = cfg => { | |
config = cfg; | |
}; | |
exports.get = () => { | |
if (!config) { | |
load(); | |
} | |
return config; | |
}; | |
//env.js | |
const fs = require("fs"); | |
const path = require("path"); | |
const environment = process.env.APP_ENV || "local"; | |
const config = require(`../config/${environment}`); | |
exports.config = config; | |
//config/local.js | |
module.exports = { | |
database: { | |
url: "postgres://@127.0.0.1:5432/svc_insurance_development", | |
ssl: false | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment