Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass a version to Knex #10941

Closed
3 tasks done
joeinnes opened this issue Jan 9, 2022 · 2 comments · Fixed by #10960
Closed
3 tasks done

Can't pass a version to Knex #10941

joeinnes opened this issue Jan 9, 2022 · 2 comments · Fixed by #10960
Labels

Comments

@joeinnes
Copy link
Contributor

joeinnes commented Jan 9, 2022

Preflight Checklist

Describe the Bug

DB_VERSION does not get passed to Knex. This is not strictly a bug I suppose, but more of a quirk. Knex considers the version not to be part of the connection info, but top-level. This means that setting DB_VERSION results in the property getting added to the connection configuration rather than top level.

Options I can see:

Happy to quickly test and then put in a PR for the latter if it helps.

From the docs:

All DB_* environment variables are passed to the connection configuration of a Knex instance (opens new window). Based on your project's needs, you can extend the DB_* environment variables with any config you need to pass to the database instance.

From Knex's docs:

Note: The database version can be added in knex configuration, when you use the PostgreSQL adapter to connect a non-standard database.

const knex = require('knex')({
  client: 'pg',
  version: '7.2',
  connection: {
    host : '127.0.0.1',
    port : 3306,
    user : 'your_database_user',
    password : 'your_database_password',
    database : 'myapp_test'
  }
});

To Reproduce

N/A

Errors Shown

N/A

What version of Directus are you using?

9.4.3

What version of Node.js are you using?

14.16.0

What database are you using?

Postgres 12.5 (via https://bit.io)

What browser are you using?

Brave

What operating system are you using?

macOS

How are you deploying Directus?

Docker

@joeinnes
Copy link
Contributor Author

joeinnes commented Jan 9, 2022

FWIW I also contacted the folks at bit.io and suggested they fix their Postgres.

@Oreilles
Copy link
Contributor

Add version: env.DB_VERSION here:

This is a good solution, I'd gladly review your PR.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants