Open CodyEakins opened 4 years ago
Still looking for this in 2021 hahaha
it appears that if the file you specify with --knexfile
exports an initialized knex instance, it will suffice. i think --knexpath
was basically merged into --knexfile
and dropped as a separate command.
it appears that if the file you specify with --knexfile exports an initialized knex instance, it will suffice.
Does that work for you? When I do that I get a different error about SELECT * with no tables specified is not valid
the source of which is identified in this comment to be exporting a knex instance from knexfile rather than a config object.
Looking at the code it seems that knexpath
is currently unused, but that it is/was intended to point to the knex cli file, not a knex instance.
https://github.com/knex/knex/blob/939d8a219c432a7d7dcb1ed1a79d1e5a4686eafd/bin/cli.js#L94-L98
When using knex migrate:latest --knexfile ./app/core/configs/knex/knex.js
I get the same errors
Working directory changed to C:\projetos\x-api\app\core\configs\knex
calling knex without a tableName is deprecated. Use knex.queryBuilder() instead.
select * - SELECT * with no tables specified is not valid
error: select * - SELECT * with no tables specified is not valid
Has anyone found a solution? I get the same when using up. my knex.js
const env = process.env.NODE_ENV || 'development';
const config = require('./config')[env];
const knex = require('knex')(config);
module.exports = knex;
my configs
const development = {
client: 'pg',
connection: {
host: 'xxxx.x.x',
user: 'postgres',
password: 'pass',
database: 'dbname,
port: xxxx,
},
migrations: {
migrations: {
tableName: 'knex_migrations',
directory: './app/core/configs/knex/db/migrations'
},
}
}; ....
The docs do not offer enough information on the
--knexpath
flag...It should cover at least two key concerns: (1) What does the
--knexpath
flag do? (2) And how does a developer properly use the--knexpath
flag (by example)?But currently, this is all we're left with:
This definition is too broad.
In my mind, I should be able to use this flag to pass a pre-configured
knex
instance to the CLI for use in operations likemigrate:latest
.However, when I run:
knex migrate:latest --knexpath ./services/knex.js
I get an error:
Error: No default configuration file [...] found and no commandline connection parameters passed
This could be just a bug, or an issue with how I am using
--knexpath
(without aknexfile.js
)...But I can't know for sure, because the docs do not cover this.