week5-node-express-knex-pg/db/knexfile.cjs

99 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2024-10-21 17:09:40 +01:00
// Update with your config settings.
const dir = process.cwd();
const env = process.env.ENVIRONMENT || "";
const config =
env === "development"
? require("dotenv").config({ path: dir + "/.env" })
: require("dotenv").config({ path: "../.env" });
//const config = require("dotenv").config({ path: dir + "/.env" });
console.log(config);
/**
* @type { Object.<string, import("knex").Knex.Config> }
*/
exports.development = {
client: "postgresql",
connection: {
database: config.parsed.DEV_DB, // env var: PGDATABASE YOUR UEA username
user: config.parsed.DEV_USER, // env var: PGUSER YOUR UEA username
password: config.parsed.DEV_PASSWORD // env var: PGPASSWORD YOUR UEA password
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: "knex_migrations"
},
seeds: {
directory: "./seeds"
}
};
exports.production = {
client: "postgresql",
connection: {
host: process.env.DEPLOYBOT_DB_HOST,
database: process.env.DEPLOYBOT_DB_NAME,
user: process.env.DEPLOYBOT_DB_USER,
password: process.env.DEPLOYBOT_DB_PASS,
port: process.env.DEPLOYBOT_DB_PORT
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: "knex_migrations"
}
};
// module.exports = {
// development: {
// client: "postgresql",
// connection: {
// database: "6057", // env var: PGDATABASE YOUR UEA username
// user: "postgres", // env var: PGUSER YOUR UEA username
// password: "12345" // env var: PGPASSWORD YOUR UEA password
// }
// },
// staging: {
// client: "postgresql",
// connection: {
// database: "my_db",
// user: "username",
// password: "password"
// },
// pool: {
// min: 2,
// max: 10
// },
// migrations: {
// tableName: "knex_migrations"
// }
// },
// production: {
// client: "postgresql",
// connection: {
// database: "my_db",
// user: "username",
// password: "password"
// },
// pool: {
// min: 2,
// max: 10
// },
// migrations: {
// tableName: "knex_migrations"
// }
// }
// };