-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathknexfile.js
More file actions
56 lines (48 loc) · 1.53 KB
/
Copy pathknexfile.js
File metadata and controls
56 lines (48 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Update with your config settings.
/**
* @type { Object.<string, import("knex").Knex.Config> }
*/
const { getDbSettings } = require('./db');
const readline = require('readline');
async function verifyAcknowledgement() {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const userInput = await new Promise((resolve) => {
rl.question('> ', (answer) => {
rl.close();
resolve(answer);
});
});
if (userInput.trim() !== 'ack') {
throw new Error('❌ Acknowledgment not received. Aborting connection to the database and not applying migrations.');
}
}
module.exports = {
client: 'pg',
connection: async () => {
const dbSettings = await getDbSettings();
console.log(`\n⚠️ !!!! IMPORTANT !!!! ⚠️
Before proceeding with migrations, verify your changes in migration files
and apply them on the local database first.
Check if the output above says "Environment: local".
If you are sure, you can proceed with migrations on remote database.
Please acknowledge this message by typing "ack" and pressing Enter. `);
await verifyAcknowledgement();
return {
host: dbSettings.databaseHost,
database: dbSettings.databaseName,
port: dbSettings.databasePort,
user: dbSettings.databaseUsername,
password: dbSettings.databasePassword,
ssl: dbSettings.ssl,
};
},
migrations: {
directory: __dirname + '/knex/migrations',
},
seeds: {
directory: __dirname + '/knex/seeds'
}
};