My concern: I am facing an issue where the
console.log('tableNobject: ', tableNobject)
does not get logged in my knex migration script.I have attempted the following code snippets:
//solution A
export async function up(knex: Knex) {
const tableAobject = await knex.select('*').from('tableAobject');
console.log('tableAobject: ', tableAobject);
}
//solution B
export async function up(knex: Knex) {
await knex.select('*').from('tableBobject').then((tableBobject) => {
console.log('tableBobject: ', tableBobject);
});
}
However, the output on my terminal is as follows:
Migration Starting ...
Migrated
Migration Done.
These logs are from our migration script where we invoke database.migrate.latest()
The expected terminal output for the provided code should be something like this:
Migration Starting ...
tableNobject: [
{
id: 'randomId'
someData: 'someDataString'
...
},
...
]
Migrated
Migration Done.
I am aware that logging tables fetched through knex is feasible because when I ran a test script outside the migration flow, I was able to log the table data without any issues.
I have also experimented with different settings additions such as:
const configA = {
...
debug: true,
}
const configB = {
...
log: {
warn(message) {
console.log(message)
},
error(message) {
console.log(message)
},
deprecate(message) {
console.log(message)
},
debug(message) {
console.log(message)
},
}
}
const configC = {
...
debug: true,
log: {
warn(message) {
console.log(message)
},
error(message) {
console.log(message)
},
deprecate(message) {
console.log(message)
},
debug(message) {
console.log(message)
},
}
};
Despite trying out the above settings variations, they do not provide the desired logging output in the terminal.
Here are the base settings (not sure if these add any value):
const config = {
client: 'postgresql',
connection: {
host: '127.0.0.1',
port: '5432',
database: 'projectName_develop',
user: 'user',
password: 'dev',
},
pool: {
min: 2,
max: 10,
},
migrations: {
tableName: 'knex_migrations',
directory: path.join(__dirname, 'migrations'),
},
seeds: {
directory: path.join(__dirname, 'seeds'),
},
asyncStackTraces: true,
};