I am quite new to using github etc. basically my situation is I have my development and production DB's wired up through a knexfile.js (I am using knex and PostgreSQL). The credentials for my production DB is okay:
production: {
client: 'postgresql',
connection: {
connectionString: process.env.DATABASE_URL, //get from heroku
ssl: { rejectUnauthorized: false },
},
pool: {
min: 2,
max: 10,
},
migrations: {
tableName: 'knex_migrations',
},
},
}
But my development DB has my credentials written into it - I obviously don't want these going up to GitHub.
development: {
client: 'postgresql',
connection: {
database: 'biblion',
user: 'USERNAME',
password: 'PASSWORD',
},
pool: {
min: 2,
max: 10,
},
migrations: {
tableName: 'knex_migrations',
},
},
I tried putting my knexfile.js into .gitignore but that broke things so I had to do a hard reset to an earlier git commit and now I am a bit stuck about how to proceed. I believe I may have to use a .env file but I am uncertain about the process for doing this, properly adding the credentials to the .env calling those in the knexfile.js then safely pushing this up to GitHub.
I'd be grateful for some guidance!