question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document knexfile options

See original GitHub issue

Currently documentation for the knexfile is severely lacking. I wasted a couple of hours trying to configure the directory where migrations are stored, and writing an almost complete bug report before I decided to try some more random things and see if anything would work. As it turns out the way to configure migrations in the knexfile is to use a migrations: {} object inside the environment object.

I know what you’re thinking: “This guy is stupid! Just reading the default knexfile.js would have saved him all the trouble”.

However I don’t like the idea of having two database configuration files laying around in my project, so early on I converted the default knexfile.js into something that reads my existing database configuration. And anyway, an automatically generated file is not the best documentation medium there is. It would be nice to have the various options with the rest of the documentation.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:8
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
rapodacacommented, May 17, 2016

For those who may still be wondering how to change the migrations directory, use a knexfile.js like this:

module.exports = {
  development: {
    client: 'sqlite',
    connection: {
      filename: './db/development'
    },
    useNullAsDefault: true,
    migrations: {
      directory: './db/migrations'
    }
};
4reactions
Pomaxcommented, Jun 20, 2017

@elhigu please don’t make that claim. Writting “some text” might be easy, but writing decent documentation is a fair amount of work. And writing good documentation is actually quite hard and something most people are not good at, through no fault of their own.

But, if you think it’s easy, then maybe you have experience writing documentation and you’ve gotten good at in. In which case, I’m sure I speak for everyone in this comment thread when I say that I am greatly looking forward to your PR that adds that documentation, or sets up the stubs so that you can work with @tgriesser to refine it into something that benefits everyone who relies on Knex, now or in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrations | Knex.js
Migrations use a knexfile, which specify various configuration settings for ... a knexfile.js, you can use the migration tool to create migration files...
Read more >
Knex cheatsheet - Devhints
One-page guide to Knex: usage, examples, and more. Knex is an SQL query builder for Node.js.This guide targets v0.13.0.
Read more >
Knex.js Tutorial For Beginners - Shahed Nasser
This will create the seed file users.js inside db/seeds . The knexfile option specifies the location of knexfile.js .
Read more >
Configuring Knex - DEV Community ‍ ‍
How to set up a knexfile to connect Knex to a SQLite3 database. Knex is a query builder that supports many types of...
Read more >
Why yarn knex is not migrating in local repo - Stack Overflow
Where is the knexfile. · No, both files were in a different folder. · then, you may need to define where is your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found