#6048·knex

Knex Migrate MSSQL error

Author: ping-samanthamCreated Mar 27, 2024Updated Sep 23, 2026
LabelsNG_bug

Environment

Knex version: 3.1.0 Database + version: MSSQL @smorey2 OS: Linux via Docker

Bug

  1. Explain what kind of behaviour you are getting and how you think it should do I'm trying to set up migrations for my sql database. When docker runs knex migrate:latest, I'm getting an error with the connectionSettings property where it is undefined.

  2. Error message image

  3. Reduced test code, for example in https://npm.runkit.com/knex or if it needs real database connection to MySQL or PostgreSQL, then single file example which initializes needed data and demonstrates the problem. Logged connection settings from knexfile- { port: 1433, host: 'host.docker.internal', user: 'xxx', password: 'xxxx', database: 'xxx', options: { useUTC: true } } image

I went to the line in the stack trace, /app/node_modules/knex/lib/dialects/mssql/index.js:342:31, and found this. image

When I console logged this.connectionSettings is undefined. I added some more logs and changed it to a path where connectionSettings is not undefined, and then it works. (I don't think this is the solution just trying to see if what I have for my connection string would be working). image